Skip to content

Commit

Permalink
Merge pull request #68 from maka-io/master
Browse files Browse the repository at this point in the history
Allow modification to GRAPHQL_ENDPOINT
  • Loading branch information
theodorDiaconu authored Sep 17, 2019
2 parents 11a17f9 + 3c5a892 commit c19008d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,22 @@ export function initialize(config = {}) {
const uploadLink = createUploadLink();

let terminatingLink;


if (!config.httpLinkOptions) {
config.httpLinkOptions = {};
}

// Backward compatibility
if (config.uri) {
config.httpLinkOptions.uri = config.uri;
} else {
// Allow GRAPHQL_ENDPOINT to be changed
config.httpLinkOptions.uri = (config.httpLinkOptions.uri) ? config.httpLinkOptions.uri : GRAPHQL_ENDPOINT;
}

// We define the HTTP Link
const httpLink = new HttpLink({
uri: GRAPHQL_ENDPOINT,
...(config.httpLinkOptions || {}),
...(config.httpLinkOptions),
});

if (meteorAccountsLink) {
Expand All @@ -52,7 +63,7 @@ export function initialize(config = {}) {

if (!config.disableWebsockets) {
wsLink = new WebSocketLink({
uri: GRAPHQL_SUBSCRIPTION_ENDPOINT,
uri: config.httpLinkOptions.uri.replace(/http/,'ws'),
options: {
reconnect: true,
connectionParams: () => ({
Expand Down

0 comments on commit c19008d

Please sign in to comment.