You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation:
With the introduction of [email protected] and [email protected], the underlying @graphql-tools/mock went from v2 to v8. Through this change, mocked resolver behaviors changed and for our teams, specifically the ability to key into request information to return corresponding mock data.
To elaborate, given there is a feature where the UI displays email information of multiple users and there is an operation that fetches user's email. The UI can either be making aliased calls or multiple calls to graphql with the user's ID expecting that the corresponding data is returned for each user ID. Previously we were able to mock the resolver dynamically with the first argument in the mocked resolver. But with graphql-toolsV8 by default, those resolvers are seemingly flattened and no longer provide the request information.
The only solution that I've found so far is to update the preserveResolver value to true (the third argument passed to mockServer of @graphql-tools/mock). I am then able to pass in makeExecutableSchema({}) of the basically the same resolver to see the request information again. (Basically the same because graphql-tools have since move the request variable to the second argument ie., getEmail: (_, { userID }) => getUserEmail(userID),)
Will be opening a PR for this for review.
The text was updated successfully, but these errors were encountered:
Motivation:
With the introduction of [email protected] and [email protected], the underlying @graphql-tools/mock went from v2 to v8. Through this change, mocked resolver behaviors changed and for our teams, specifically the ability to key into request information to return corresponding mock data.
To elaborate, given there is a feature where the UI displays email information of multiple users and there is an operation that fetches user's email. The UI can either be making aliased calls or multiple calls to graphql with the user's ID expecting that the corresponding data is returned for each user ID. Previously we were able to mock the resolver dynamically with the first argument in the mocked resolver. But with graphql-toolsV8 by default, those resolvers are seemingly flattened and no longer provide the request information.
The only solution that I've found so far is to update the preserveResolver value to true (the third argument passed to mockServer of @graphql-tools/mock). I am then able to pass in
makeExecutableSchema({})
of the basically the same resolver to see the request information again. (Basically the same because graphql-tools have since move the request variable to the second argument ie.,getEmail: (_, { userID }) => getUserEmail(userID),
)Will be opening a PR for this for review.
The text was updated successfully, but these errors were encountered: