Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apollo-boost] Ignores fetchOptions.credentials #3265

Closed
alexgorbatchev opened this issue Apr 4, 2018 · 12 comments
Closed

[apollo-boost] Ignores fetchOptions.credentials #3265

alexgorbatchev opened this issue Apr 4, 2018 · 12 comments

Comments

@alexgorbatchev
Copy link

Intended outcome:

Have credential being included with GraphQL request across different domains.

Actual outcome:

Credentials aren't included.

How to reproduce the issue:

import ApolloClient from 'apollo-boost'; 

const client = new ApolloClient({
  fetchOptions: {
    credentials: 'include',
  },
  uri: GRAPHQL_URI,
});

Version

  • "apollo-boost": "^0.1.3"

Credentials value is hardcoded over here
https://github.com/apollographql/apollo-client/blob/master/packages/apollo-boost/src/index.ts#L77

I submitted a PR at #3264

@alexgorbatchev
Copy link
Author

You can manually configure the client using the sample below:

import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';

const client = new ApolloClient({
  cache: new InMemoryCache(),
  link: new HttpLink({
    credentials: 'include',
    uri: GRAPHQL_URI,
  }),
});

@MinJieLiu
Copy link

I have the same problem.

@haflinger
Copy link

Same here.

@haflinger
Copy link

haflinger commented May 2, 2018

const client = new ApolloClient({
  cache: new InMemoryCache(),
  uri: 'http://localhost:4000/graphql',
  request: async operation => {
    operation.setContext({
      fetchOptions: {
        credentials: 'include'
      }
    });
  }
});

Here is my solution.

@MinJieLiu
Copy link

Why does the author not give priority to this bug?

@StoraH
Copy link

StoraH commented May 3, 2018

@alexgorbatchev @haflinger thank you! Spent a lite too mutch time before I found this issue. Two days I'm not getting back 😅

@wesbos
Copy link

wesbos commented May 16, 2018

whew- thank you for this - just spent the last hour trying to find out why cookies were not being sent :)

@wesbos
Copy link

wesbos commented May 16, 2018

I think this is the fix: #3387

@alexgorbatchev
Copy link
Author

@wesbos i submitted a PR with this issue #3264

@vinayan3
Copy link

vinayan3 commented Jun 7, 2018

I'm hitting this bug as well where the client I've constructed using apollo-boost is not passing along the fetchOptions and the needed credentials. I'm using the solution that @haflinger suggested.

I'm using "apollo-boost": "^0.1.7".

@hwillson
Copy link
Member

hwillson commented Jun 8, 2018

Hi all - this has been fixed by #3098, and has been merged in. It will be included in our next release (this upcoming Tuesday, June 12th). Thanks!

@leogoesger
Copy link

leogoesger commented Nov 25, 2018

@hwillson I am using "apollo-client": "^2.4.7", with "apollo-boost": "^0.1.22",. This issue is still here.

Using Appllo boost doesn't work, but apollo-client works as normal

export const client = new ApolloBoostClient({
  uri: process.env.SERVER_ADDRESS || 'http://localhost:8080/api/graphql',
  fetchOptions: {
    credentials: 'include',
  },
});
export const client = new ApolloClient({
  link: createHttpLink({
    credentials: 'include',
    uri: 'http://localhost:8080/api/graphql',
  }),
  cache: new InMemoryCache(),
});`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants