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

Add ability to process request params after they're parsed #1038

Closed
SirensOfTitan opened this issue Apr 2, 2022 · 2 comments
Closed

Add ability to process request params after they're parsed #1038

SirensOfTitan opened this issue Apr 2, 2022 · 2 comments
Milestone

Comments

@SirensOfTitan
Copy link

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

I'm trying to implement persisted queries using apollo-client's format (within extensions). Right now, it's fairly difficult to get graphql-yoga and apollo-client to work with each other when using persisted queries:

  • graphql-yoga requires query to be defined or else it'll throw a 400 before we get to onParse.
  • Apollo's terminal HTTPLink really just can either send the printed query or nothing at all.

Describe the solution you'd like
It'd be nice to have some kind of hook to process the request after graphql-yoga has parsed it out (request body parsed to JSON, etc).

Describe alternatives you've considered
As things stand today, I can try either:

  1. Sending an empty DocumentNode as the query if apollo is sending a persisted query.
  2. Parsing the request myself, and setting query if a persisted query hash exists in the request before passing into yoga (this requires parsing query params or request body twice).
    Additional context
@n1ru4l
Copy link
Collaborator

n1ru4l commented Apr 5, 2022

As mentioned in #704 this is part of the future improvements we plan for Yoga.

Enhanced Plugin System that extends the base envelop plugin system and allows fully async parse/validate hooks + also hooking into beforeParseRequest/postParseRequest and preSendResponse/postSendResponse

See https://www.figma.com/file/DpMLbOyBM2hL9RyMojbVYA/GraphQL-Yoga-Plugin-System?node-id=0%3A1

@n1ru4l
Copy link
Collaborator

n1ru4l commented Jul 5, 2022

@SirensOfTitan A heads up on this, we now have the experimental onRequestParse hook:

/**
* Use this hook with your own risk. It is still experimental and may change in the future.
* @internal
*/
onRequestParse?: OnRequestParseHook

Please notice that the API might change. We will come up with a public roadmap for GraphQL Yoga soon.

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

No branches or pull requests

3 participants