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

Must provide query string. should not be an error #3284

Closed
SivkovSavely opened this issue May 20, 2024 · 6 comments
Closed

Must provide query string. should not be an error #3284

SivkovSavely opened this issue May 20, 2024 · 6 comments

Comments

@SivkovSavely
Copy link

Hi, I need GraphQL Mesh to support automatic persisted queries (APQs). For this I created a plugin that caches incoming queries by the supplied hash and executes these queries if the query parameter hasn't been passed in the body.

The problem I'm having is in Yoga, the query parameter is mandatory. If you don't pass query in the request body, it outputs an error Must provide query string. without letting any plugin to work. So I cannot even make a workaround in my own plugin, it starts parsing the request before any of the Envelop plugin methods are executed.

Can you please either add some callbacks in Envelop (if so, I'll probably need to add a feature request in its repo?) or allow the missing query parameter somehow. Maybe allow missing query param if APQ's fields are present, like extensions.persistedQuery.sha256Hash or something.

I've added a plugin source code if you need it for context (keep in mind it's a little messy because it's a prototype): https://gist.github.com/SivkovSavely/596cc1c40a53ab0b90bf9811f6333e31

Maybe the APQ support in Mesh can be a feature request on its own...

@ardatan
Copy link
Collaborator

ardatan commented May 20, 2024

We already have tests for our APQ plugin, and those tests don't have any query property in the body.
Must provide query string error should not be thrown because we handle the extensions and pass query before handling those GraphQL parameters.
https://github.com/dotansimha/graphql-yoga/blob/main/packages/plugins/apq/src/index.ts#L90
Could you provide a reproduction on CodeSandbox or StackBlitz? Thanks!

@SivkovSavely
Copy link
Author

I don't explicitly use Yoga, I use Mesh, which contains Yoga (if I were to believe the Mesh's error messages), so I believe I don't have access to the APQ plugin of Yoga in Mesh, although that would have been very awesome. Maybe I'm missing something and I can actually enable Yoga plugins in Mesh.

I will create a minimal reproducing example and link a repo to it here.

@ardatan
Copy link
Collaborator

ardatan commented May 20, 2024

You don't need anything specific to do to use Yoga plugins in Mesh. All Yoga plugins can be used in Mesh either in declarative or programmatic ways;

plugins:
  - apq: {}

So all Envelop plugins are Yoga plugins while all Yoga plugins are Mesh plugins. They are extended versions of each.

@SivkovSavely
Copy link
Author

Thank you, I didn't know I could use the APQ plugin in Mesh directly. I tried it, and it works, the request passes through when I have query but it doesn't pass when I don't have query.

Here is the reproduction repository: https://github.com/SivkovSavely/api-gate-mvp-repro

@ardatan
Copy link
Collaborator

ardatan commented May 20, 2024

Let's close this one then create an issue on Mesh because this looks like an issue with it :) Could you do that so we can track from there?

@SivkovSavely
Copy link
Author

Sure thing! Here it is. ardatan/graphql-mesh#6998 I'll close this one then

@SivkovSavely SivkovSavely closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
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

2 participants