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

Export GraphQL Root Types #2738

Open
1 task done
avedetvedea opened this issue Mar 23, 2023 · 2 comments
Open
1 task done

Export GraphQL Root Types #2738

avedetvedea opened this issue Mar 23, 2023 · 2 comments
Labels

Comments

@avedetvedea
Copy link

avedetvedea commented Mar 23, 2023

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Many people over many years have requested having the Root Query type to be exported to be able to use the technique of Mutation Payload Query, like so https://graphql-rules.com/rules/mutation-payload-query/, in which you return the whole Root Query type to allow the client to get the whatever data they want.

Describe the solution you'd like

For a mutation PollRatingSubmit, having a payload:


@ObjectType()
export class PollRatingSubmitPayload {
  userErrors: UserErrorDto[];
  query: QueryDto;
}

I want to achieve that QueryDto. There may be different strategies to consider, like running these two resolvers in sequence or in parallel https://discord.com/channels/520622812742811698/1088106037401366588/1088412449037885510.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

As put in the linked 'rules' site, "... allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application." I'm using Relay GQL client which will allow me to simply spread their fragments in the Query payload and update the cache and UI whenever some of my mutations have effects on rather less relevant parts of the graph.

@tugascript
Copy link
Contributor

I know I am being a broken clock here, always touching the same thing, but could you try to create a Draft PR for this?

The field decorator would be here: https://github.com/nestjs/graphql/blob/master/packages/graphql/lib/decorators/field.decorator.ts

Definitions (on the Apollo Driver) are generated here: https://github.com/nestjs/graphql/blob/master/packages/apollo/lib/drivers/apollo.driver.ts#L30

Personally I already tried to implement this one year ago or so but couldn't, I might try it when I have some time, but ideas on how to implement this would be helpful, for both code-first and schema-first.

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

No branches or pull requests

2 participants