Skip to content

Commit

Permalink
Merge pull request #72 from IulianCrudu/fix-upload-links
Browse files Browse the repository at this point in the history
fixed upload links
  • Loading branch information
theodorDiaconu authored Sep 19, 2019
2 parents 72ae31b + 71a981b commit 68b2d78
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ApolloClient from 'apollo-client';
import { WebSocketLink } from 'apollo-link-ws';
import { HttpLink } from 'apollo-link-http';
import { createHttpLink } from 'apollo-link-http';
import ApolloLink from 'apollo-link';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { getMainDefinition } from 'apollo-utilities';
Expand Down Expand Up @@ -31,27 +31,27 @@ export function initialize(config = {}) {
Object.assign(Config, config);
Object.freeze(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;
config.httpLinkOptions.uri = config.httpLinkOptions.uri
? config.httpLinkOptions.uri
: GRAPHQL_ENDPOINT;
}

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

const uploadLink = createUploadLink(config.httpLinkOptions);

// We define the HTTP Link
const httpLink = createHttpLink(config.httpLinkOptions);
console.log(config.httpLinkOptions);
if (meteorAccountsLink) {
terminatingLink = ApolloLink.concat(meteorAccountsLink, uploadLink, httpLink);
} else {
Expand All @@ -63,7 +63,7 @@ export function initialize(config = {}) {

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

0 comments on commit 68b2d78

Please sign in to comment.