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
Submitted on behalf of a third-party: add mergeResolvers #1084
Submitted on behalf of a third-party: add mergeResolvers #1084
Conversation
@finnigantime: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
| { [key: string]: ResolvedValue | ResolverFunction } | ||
| null | ||
| ResolvedValue | ||
| ResolverMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the two typing changes from the original gist are to add | ResolvedValue | ResolverMap
here.
A ResolverMap value can be a ResolvedValue directly - no need for a ResolverFunction. This seems to work fine in our testing.
The other change is to allow a ResolverMap value to be another ResolverMap. The ResolverMap can be multilevel. For instance, one test we wrote passes:
const client = mockClient({
WorkItem: () => ({
queue: () => ({
id: () => 'test-queue-id-1',
}),
}),
});
(here, mockClient is our local mock Apollo client and it calls mergeResolvers() with the first argument being our base set of mock resolvers for all tests, and the second argument being the test-specific resolver override map)
Just throwing out a gentle bump here... what's the status of this PR? |
I would love to get this in. On my end, this is ready to merge. We left a note to @hellendag on the gist to notify. Repo admins - ok to merge this? |
@finnigantime Why are there no unit tests for |
Quite interested in this and wondering what is blocking it. |
Nothing from my end |
Wondering about adding to graphql-tools-fork. What does this do that mergeDeep does not? |
I see, this runs both resolvers to make sure to return something. |
Thank you @finnigantime for this contribution ! We are planning to merge your code with |
|
TODO:
Implements #1083.
This PR takes an existing well-publicized gist https://gist.github.com/hellendag/2aa9ad1f9b771f38802760c269bb1b76 (with two small Typescript typing changes) and exposes it as part of graphql-tools. Currently we copy-pasted the gist into our codebase but we don't want to have to maintain it ourselves and keep it in sync with the rest of graphql/graphql-tools. It is generally useful for schema mocking and makes sense to expose in the graphql-tools lib.