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

callback function for onSchemaLoadOrUpdate when upgrading from AS v3 to AS v4 #7828

Closed
simpyparveen opened this issue Jan 31, 2024 · 3 comments

Comments

@simpyparveen
Copy link
Contributor

simpyparveen commented Jan 31, 2024

Issue Description

I have a gateway defined as follows:

 const gateway: GraphQLService = {
        load: async () => (await {
            schema: server.systemSchema,
            executor: (args) => execute({
                ...args,
                schema: server.systemSchema,
                contextValue: args.context,
                variableValues: args.request.variables
            })
        } as GraphQLServiceConfig),
        stop: async () => {},
        onSchemaChange: (callback: SchemaChangeCallback) => {
            server.updateSchema = callback;
            return () => {};
        }
    };
**What will be the equivalent gateway in AS v4 ??**
    I made an attempt to do:
    const gateway: GatewayInterface = {
        load: async () => (await {
            schema: server.systemSchema,
            executor: (args) => execute({
                ...args,
                schema: server.systemSchema,
                contextValue: args.context,
                variableValues: args.request.variables
            })
        } as GatewayLoadResult),
        stop: async () => {},
        onSchemaLoadOrUpdate (callback) {
            callback({ apiSchema: schema } as any);
            return () => {};
        }
    };
   
But i get an error thrown when i update the server.  Potentially because I remove the line `server.updateSchema = callback;`. How should I perform server.updateSchema in modified gateway ???

Need aa solution.

Link to Reproduction

https://www.apollographql.com/docs/apollo-server/migration/#executor

Reproduction Steps

No response

@trevor-scheer
Copy link
Member

Can you provide more details on the error? As far as I can tell, schema is undefined in the onSchemaLoadOrUpdate function, but there is a fair amount of context missing from the code so I can't be sure of much.

I can really only be more helpful if you provide a reproduction with detailed instructions on how to trigger the error. Happy to reopen this with a reproduction.

@trevor-scheer trevor-scheer closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2024
@simpyparveen
Copy link
Contributor Author

simpyparveen commented Feb 1, 2024

Copy link
Contributor

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants