Skip to content

Return only fields requested in GQL query #1339

Answered by kettanaito
kgpax asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @kgpax. Thanks for raising this.

Filtering out only the requested fields is done by the server, and more specifically, by passing the full resolved payload through the graphql package, where it also does a few other things like field value validation, directives, etc. This is too much for MSW to ship as default behavior, and even as an opt-in behavior.

We did, however, provide an example of how you can achieve the fields filtering identical to an actual server:

graphql.query('GetUser', async (req, res, ctx) => {
const executionResult = await executeGraphql({
schema: buildSchema(schema),

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kgpax
Comment options

@kettanaito
Comment options

Answer selected by kgpax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #1338 on July 17, 2022 16:34.