You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [GraphQL Trusted Documents](https://benjie.dev/graphql/trusted-documents) and
196
+
[Techniques to Protect Your GraphQL API](https://benjie.dev/talks/techniques-to-protect) at benjie.dev
197
+
- [@graphql-codegen/client-preset persisted documents](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#persisted-documents) or [graphql-codegen-persisted-query-ids](https://github.com/valu-digital/graphql-codegen-persisted-query-ids#integrating-with-apollo-client) for Apollo Client
198
+
- [Persisted queries in Relay](https://relay.dev/docs/guides/persisted-queries/)
199
+
- [Persisted queries in URQL](https://www.npmjs.com/package/@urql/exchange-persisted)
200
+
- [Persisted documents in gql.tada](https://gql-tada.0no.co/guides/persisted-documents)
201
+
- [persisted queries with `fetch()`](https://github.com/jasonkuhrt/graffle/issues/269)
202
+
155
203
### Control schema introspection
156
204
205
+
(Unnecessary if you only allow trusted documents.)
206
+
157
207
Introspection lets clients query the structure of your schema, including types
158
208
and fields. While helpful during development, it may be an unnecessary in
159
209
production and disabling it may reduce your API's attack surface.
@@ -173,6 +223,8 @@ control as needed for your tools and implementation.
173
223
174
224
### Limit query complexity
175
225
226
+
(Can be a development-only concern if you only allow trusted documents.)
227
+
176
228
GraphQL allows deeply nested queries, which can be expensive to resolve. You can prevent this
177
229
with query depth limits or cost analysis.
178
230
@@ -405,15 +457,16 @@ Before deploying, confirm the following checks are complete:
405
457
- Development-only checks are removed from the production build
406
458
407
459
### Schema security
408
-
- Introspection is disabled or restricted in production
409
-
- Query depth is limited
410
-
- Query cost limits are in place
411
460
- Authentication is required for requests
412
-
- Authorization is enforced in resolvers
461
+
- Authorization is enforced via business logic
413
462
- Rate limiting is applied
463
+
- Only allow trusted documents, or:
464
+
- Introspection is disabled or restricted in production
465
+
- Query depth is limited
466
+
- Query cost limits are in place
414
467
415
468
### Performance
416
-
- `DataLoader` is used to batch database access
469
+
- `DataLoader` is used to batch data fetching
417
470
- Expensive resolvers use caching (request-scoped or shared)
418
471
- Public queries use HTTP or CDN caching
419
472
- Schema is reused across requests (not rebuilt each time)
0 commit comments