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

Hot schema reloading with grapphql subscription with WS support #3430

Open
merlor opened this issue Sep 9, 2024 · 0 comments
Open

Hot schema reloading with grapphql subscription with WS support #3430

merlor opened this issue Sep 9, 2024 · 0 comments

Comments

@merlor
Copy link

merlor commented Sep 9, 2024

I'm trying to add the "hot schema reloading", as seen here https://the-guild.dev/graphql/stitching/handbook/architecture/hot-schema-reloading, with the subscriptions support seen here in the ws section https://the-guild.dev/graphql/yoga-server/docs/features/subscriptions#graphql-over-websocket-protocol-via-graphql-ws

Basically, where fields that require a schema such as:

createYoga({
  schema: createSchema({...}),
...}

or

onSubscribe: async (ctx, msg) => {
....
 const args: ExecutionArgs = {
                        schema: envelop.schema,
...},
}

I susbtitute them with a function that can be called to reload the new schema:

createYoga({
  schema: () =>loader.schema,
...}

or

onSubscribe: async (ctx, msg) => {
....
 const args: ExecutionArgs = {
                        schema: ()=> loader.schema,
...},
}

This implementation works with queries and mutations API but it doesn't work with subscriptions:

  • yogaServer.getEnveloped({...}) return the error No schema found for this request. Make sure you use this plugin with GraphQL Yoga. (returned from line 53 in the file use-schema.js) because the object schemaByRequest is empty
  • I don't know if it work as intended but I've see a weird behaviour: when I make a query or a mutation, the function onRequestParse (use-schema.js, row 34, that fill the object schemaByRequest) is called first then the function OnEnveloped(use-schema.js, row 47) ; if i make a subscription, the OnRequestParse function is never called, the item schemaByRequest stay empty and the OnEnveloped fails.

So, apparently, this function is not available (or is restricted from a bug)

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

1 participant