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

feat(useQuery): accept client option #95

Merged

Conversation

alexkirsz
Copy link
Contributor

Fixes #85.

I chose to preserve hooks invariants by still calling the useApolloClient hook despite the Apollo client being passed from the options.

I also implemented the same behaviour for useMutation and useSubscription.

This allows for creating custom hooks that address a specific client, e.g.:

function useBooksQuery(query, options) {
  const booksClient = useContext(BooksClientContext);
  return useQuery(query, { client: booksClient, ...options });
}

@alexkirsz alexkirsz changed the title feat(useQuery): accept client prop feat(useQuery): accept client option Feb 25, 2019
@Jdender
Copy link

Jdender commented Feb 28, 2019

This would be extremely useful for multiple clients instead of having to mess around with the context.

@trojanowski trojanowski merged commit 0ba17aa into trojanowski:master Mar 1, 2019
@trojanowski
Copy link
Owner

Thanks @alexkirsz. Published with release v0.4.3.

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

Successfully merging this pull request may close these issues.

3 participants