-
Notifications
You must be signed in to change notification settings - Fork 568
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
[v3] Bypass GraphQL endpoint checking #2132
Comments
What if This might then also be capable of handling the const plugin = {
async onRequestParse(ctx) {
const url = new URL(ctx.request.url)
if (url.pathname.startsWith('/graphql/')) {
const documentSha = url.pathname.replace('/graphql/', '')
return {
async onRequestParseDone(ctx) {
if (Array.isArray(ctx.requestParserResult)) {
return
}
const query = await store.load(documentSha)
ctx.setRequestParserResult({
extensions: ctx.requestParserResult.extensions,
query,
variables: ctx.requestParserResult.variables,
})
},
}
}
},
};
const yoga = createYoga({
graphqlEndpoint: (url) => url.startsWith("/graphql"),
plugins: [plugin],
}); This would probably be a breaking change for the Maybe we could instead allow from within a plugin to overwrite the check for whether a request should hit the graphql.layer |
Thanks for your response!
Make sense, it's very extensible! |
I have a related issue (may be related to GraphiQL in part). I want to serve it from const yoga = createYoga<{ req: FastifyRequest; reply: FastifyReply }>({ ..., graphqlEndpoint: "/graphql" }) and GraphiQL UI is loading on |
We have the same issue at Nhost. In our CLI, Functions are served at In production, the endpoint is different, like this: Currently, GraphQL Yoga v3 is unusable on Nhost. This was not an issue with GraphQL Yoga v2. |
#2266 |
@ardatan That worked great; the GraphQL API is now working with But now, there is an issue with GraphiQL. Should we create a separate issue for it? |
Should be fixed in 3.3.1 |
Is your feature request related to a problem? Please describe.
Yoga v3 introduces the
graphqlEndpoint
option, but it seems there is no way to bypass the endpoint URL checking.We use the Next.js API routes to mount Yoga on the following URL:
Actually,
[operationName]
part is not used in our application, but it is useful for monitoring etc.However, Yoga v3 simply compares the
graphqlEndpoint
option to the URL, so it can not handle URLs with dynamic paths like this anymore.In practice, the API route in Next.js is only called if the URL matches, so the additional endpoint checking by Yoga is not necessary I think.
Describe the solution you'd like
Could you consider adding a way to bypass the endpoint checking?
For example:
graphqlEndpoint: false
Describe alternatives you've considered
Support for
path-to-regex
, such asgraphqlEndpoint: 'api/graphql/:operationName'
Additional context
Workaround currently in use:
The text was updated successfully, but these errors were encountered: