Check GraphQL-over-HTTP requests, enforcing several limits and restrictions to mitigate the attack surface of GraphQL APIs.
- Navigate to the
examples/graphql/graphql-validationdirectory in a terminal. - Start the API Gateway by executing
membrane.sh(Linux/Mac) ormembrane.cmd(Windows). - Query the protected API by opening the
requests.httpfile in VS Code or IntelliJ IDEA to execute the querries.
Let's examine the proxies.xml file.
<router>
<api port="2000">
<request>
<graphQLProtection maxRecursion="2" />
</request>
<target url="https://www.predic8.de/fruit-shop-graphql" />
</api>
</router>We define an <api> component with the graphQLProtection plugin inside, running on port 2000 and routing to Fruit Shop GraphQL.
We validate requests only; using the default configuration of the plugin (except for recursion):
- Don't allow GraphQL extensions.
- Only allow queries over HTTP methods
GETandPOST. - Max recursion depth of 2 (so it catches before nesting depth in this example).
- Max nesting depth of 7.
- Maximum number of mutations in a query of 5.
See:
- graphQLProtection reference for detailed configuration