Skip to content

Integrating query complexity plugin #373

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

Closed
Hossein-s opened this issue Aug 17, 2019 · 3 comments
Closed

Integrating query complexity plugin #373

Hossein-s opened this issue Aug 17, 2019 · 3 comments

Comments

@Hossein-s
Copy link

Hossein-s commented Aug 17, 2019

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

To use graphql-query-complexity, we need access to schema. and as we are passing plugins in GraphQLModule options, there's no way to configure this plugin.

Expected behavior

Access schema in plugins configuration.

@frieck
Copy link

frieck commented Aug 28, 2019

Is there any "alternative" way to use query complexity validation now?
Thanks

@jorisvddonk
Copy link

Apollo Server plugins can get access to the schema via the GraphQLServiceContext that's passed to the serverWillStart plugin hook. Thus, you can create your own plugin that captures the schema and then uses it within didResolveOperation. See this gist for an example plugin, and here's how you use it:

        GraphQLModule.forRoot({
            autoSchemaFile: "schema.gql",
            plugins: [
                new ApolloComplexityPlugin(20) // max complexity is 20
            ]
        })

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants