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

Feature Request: integrate with apollo-link-timeout #235

Open
komyg opened this issue Nov 2, 2019 · 6 comments
Open

Feature Request: integrate with apollo-link-timeout #235

komyg opened this issue Nov 2, 2019 · 6 comments
Labels
enhancement💡 feature Feature: new addition or enhancement to existing solutions help wanted 🛠 question❔

Comments

@komyg
Copy link

komyg commented Nov 2, 2019

Hi,

Is it possible to configure a timeout for the Apollo Link REST calls? I tried to use the Apollo Link Timeout, but it is only working for the standard Graphql calls.

My configuration is this:

const timeoutLink = new ApolloLinkTimeout(Number(process.env.REACT_APP_TIMEOUT));

const restLink = new RestLink({
  credentials: 'include',
  uri: process.env.REACT_APP_API_URL,
});

const httpLink = new HttpLink({
  credentials: 'include',
  uri: process.env.REACT_APP_GRAPHQL_URL,
});


export const apolloClient = new ApolloClient({
  link: ApolloLink.from([authLink, errorLink, timeoutLink, restLink, httpLink]),
  connectToDevTools: true,
  cache: localCache,
  resolvers: localResolvers,
  assumeImmutableResults: true,
});

Am I doing something wrong?

Thanks,
Felipe

/label question

@fbartho
Copy link
Collaborator

fbartho commented Nov 3, 2019

Hi @komyg !!

I had never heard of ApolloLinkTimeout!

Looking at the implementation here: https://github.com/drcallaway/apollo-link-timeout/blob/master/src/timeoutLink.ts

I see that they add a fetchOptions hash & an AbortController to Apollo’s Link Context I think we could integrate with that.

If you’re interested in contributing support for that, let me know! I hesitate to enable something like that by default for everyone, since they might want different timeouts for GraphQL vs link-rest calls, and maybe different per REST endpoint. But maybe we can build a parallel feature.

@komyg
Copy link
Author

komyg commented Nov 6, 2019

Hi @fbartho,

Sorry for the delay in my response.

Yes, I would like to help, but currently I am delivering a big project, so I would only be available after november 15. Is that ok?

Thanks,
Komyg

@fbartho
Copy link
Collaborator

fbartho commented Jan 5, 2022

@komyg please let me know if you or someone else wants to contribute a timeout-integration! Happy to review a PR.

@fbartho fbartho added enhancement💡 feature Feature: new addition or enhancement to existing solutions labels Jan 5, 2022
@komyg
Copy link
Author

komyg commented Feb 7, 2022

Hi @fbartho, I am sorry, but I don't have the time to contribute right now.

Feel free to close this issue, if you want.

@fbartho fbartho changed the title How to add timeout to REST calls Feature Request: integrate with apollo-link-timeout Feb 7, 2022
@wootencl
Copy link

wootencl commented Oct 27, 2022

@fbartho looking at possibly taking a crack at implementing this feature but I'll admit I'm not familiar with apollo-link-rest's codebase. Any additional insight into the implementation would be greatly appreciated 🙏.

@fbartho
Copy link
Collaborator

fbartho commented Oct 27, 2022

@wootencl — I haven’t looked at Apollo-link-timeout, but reading the description — maybe it’s worth reviewing that library and the PR: #296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement💡 feature Feature: new addition or enhancement to existing solutions help wanted 🛠 question❔
Projects
None yet
Development

No branches or pull requests

3 participants