When a Strapi GraphQL API is the right way to expose content
Choose GraphQL when a single client needs nested content in one request and the shape of that content changes from screen to screen. A front end that renders an article with its author, related items and localized fields can otherwise make several REST calls for each page view. The official GraphQL plugin adds one endpoint over your content types, and with Shadow CRUD enabled, Strapi generates the query and mutation schema from those types without hand-written resolvers for basic reads. Strapi's self-hosted pricing page lists the GraphQL API as included in every self-hosted plan, so licensing does not decide between the two APIs. The decision rests on how your clients query content and who can reach the endpoint.
REST remains the simpler choice when responses are cached at the edge, when partners need predictable URLs for each resource, or when the team has no GraphQL experience to support in production. Map each client before deciding. List the screens or integrations, the fields each one reads, and how many REST requests each view would need today. If that number is low and stable, REST is likely enough. If clients differ widely in the fields they need, GraphQL reduces round trips and lets each consumer ask only for what it renders. Confirm that your front-end framework and any mobile client libraries support GraphQL well, and confirm which roles can run which queries, since the same permission model still governs what each caller can read.
Schedule the limits as part of launch scope, alongside the schema work. The GraphQL plugin's depth and result limits are off by default, so a query that nests relations several levels deep or requests a large page of entries is accepted until you configure a ceiling. On a public endpoint, that is a denial-of-service path: one client can request expensive relation trees while others wait. Before go-live, decide the maximum query depth and the maximum number of results per request, set them in the plugin configuration, and test them with queries that deliberately exceed each limit. Also decide whether introspection stays on in production and which operations need a policy check. Confirm the exact setting names and default values in the plugin documentation for your Strapi version, because they can change between releases.
How a GraphQL request moves through Strapi
A GraphQL request starts at the endpoint, which is the trust boundary where anonymous and signed-in traffic both arrive. Before any resolver runs, depth and result limits and permission checks decide whether the query proceeds. Shadow CRUD or custom resolvers then call the Document Service API, which reads from the database. Check each hand-off: limits are off by default, so you must set them, and policies on custom resolvers are your responsibility.
The path a GraphQL query takes from the endpoint to the database and back.
Which GraphQL configuration options fit which situation
This table compares the main ways to expose Strapi content over GraphQL, from Shadow CRUD alone to custom resolvers and access limits. Read each row for when the option fits, what it adds to build and review work, and the risk it carries if left unchecked.
| Option | When it fits | Build and review effort | Main risk |
|---|---|---|---|
| Shadow CRUD only | Read-only content for a front end where every content type can be public or fully private | Low build effort. Review focuses on which types are exposed and whether the public role can read them | Enabling the schema without depth and result limits leaves queries open to expensive nested requests |
| Shadow CRUD with per-type permission restrictions | Mixed content where some types are public and others are internal, drafts, or editor-only | Moderate effort. Each content type and action needs a reviewed role permission, tested for both roles | A permission missed on one type or mutation exposes data that the REST API would have protected |
| Custom resolvers for business logic | Responses need computed fields, joins across types, or logic that the generated schema cannot express | Higher effort. Resolvers need their own tests, input validation and permission checks, and a review by a developer | Custom resolvers can bypass the checks that generated resolvers apply, so authorization must be rebuilt inside them |
| Public access | Marketing sites, documentation or open catalogs where the content is meant for anyone | Low effort to set up, but the content review must confirm nothing unpublished or personal is reachable | Anonymous callers can run any allowed query, so limits and rate controls matter more |
| Authenticated access | Member areas, partner portals or editor tools that need user identity on every request | Moderate effort. Users and Permissions roles, token handling and expiry must be designed and tested | Tokens that are long-lived or shared widen the exposure of every field the role can read |
| Depth and result limits enabled | Any schema exposed to callers outside your own network, which is most production deployments | Moderate effort. Limits must be tuned against real front-end queries so legitimate pages do not break | Limits left off by default allow deeply nested or very large queries that can slow or stop the server |
How Shadow CRUD generates the schema from content types
Shadow CRUD is the automatic layer of the GraphQL plugin. It generates query and mutation types for every content type and component in your Strapi project, so editors and developers get working reads and writes without hand-written resolvers. This speed is also why the schema needs an owner. Each content type you add or change in the Content-type Builder changes the generated types, and those changes reach the GraphQL endpoint when the server loads the schema again. Confirm in your installed plugin version when regeneration happens in development and in production, and whether your deployment process must restart the server to pick up the change.
Every new type widens the attack surface. Each generated type brings queries, filter arguments, sorting and relations to other types and components, and a deep chain of relations can let one request reach far into the content graph. Schema growth is therefore also a security change. Before a new content type goes live, check which of its relations are exposed, which fields hold data that should never leave the server, and whether public or authenticated roles can reach the new operations through the Users & Permissions settings. Depth and result limits bound a single query, and they are off by default, so they belong in the same review.
Generated fields should be reviewed against what the front end actually needs. Shadow CRUD exposes everything it can derive from the model, including fields the site never renders. Export the generated schema from a staging instance and compare it with the queries your front-end repository sends, checking query names, selected fields and relations. Fields with no consumer are candidates for removal from the public role, or for a custom resolver that returns only what a page needs. Record the decision for each new type in your content model documentation so the next editor who adds a field knows its GraphQL impact before it ships.
Setting up the GraphQL plugin in a self-hosted Strapi project
This sequence takes a self-hosted Strapi 5 project from a version check to a GraphQL endpoint that exposes only the content you intend, with query depth and result size capped before any traffic reaches it. Each step closes with a check the team can repeat before moving to the next environment.
Confirm Strapi version and Node.js support
The developer checks that the project runs Strapi 5 on a Node.js version that Strapi currently supports, and that the database is one Strapi 5 supports: PostgreSQL 14 or later, MySQL 8.0 or later, MariaDB 10.3 or later, or SQLite 3. Strapi 5 runs only on Active or Maintenance LTS Node.js versions, so the platform team should confirm the Node.js line against the installation requirements before any change is made. The step is done when
npx strapi versionreports the expected Strapi release and the server starts cleanly in development.Install and enable the official GraphQL plugin
The developer installs the official GraphQL plugin into the Strapi project, enables it in the plugin configuration, and restarts the server. GraphQL is included on every self-hosted plan, so the plan choice does not change this step. The step is done when the GraphQL endpoint responds at the path the project configures and a simple query for one content type returns entries from the development database.
Review the generated schema in development
Shadow CRUD generates queries and mutations for every content type, component and relation, so the developer and content modeler review the output together. They check type names, relation fields, enum values and localized fields if internationalization is enabled. Any content type or field that should not be reachable through GraphQL is removed from the exposed set now, because Shadow CRUD can make fields available that were previously only visible in REST. The step is done when schema introspection lists exactly the types the team expected, and internal or token-related types are absent or intentionally included.
Set permissions for public and authenticated roles
The administrator sets GraphQL permissions separately for the Public and Authenticated roles in the Users & Permissions settings of the admin panel. Read access is granted only to the content types and actions the front end needs, and mutations stay disabled for public users unless a documented workflow requires them. Any custom resolver or policy added later must respect these grants. The step is done when an anonymous request for a restricted type returns a permission error, and a test account for each role returns only the intended fields.
Configure depth and result limits
Depth and result limits are off by default, so an unconfigured endpoint will accept deeply nested queries and requests for very large result sets. The architect and developer set a maximum query depth and a maximum number of results per request in the plugin configuration. The values come from the nested relations the front end actually uses, plus a margin agreed with the security owner, and should not be copied from examples. The step is done when a query above the limit returns an error in development and the configuration file is committed to version control.
Test representative and hostile queries
The QA or security engineer builds a test set from the queries the front end sends, then adds hostile ones: loops through nested relations, requests for entire collections without pagination, aliases that repeat the same expensive field, and introspection from anonymous users. The set runs against development for each role, with status codes and response times recorded. Rate limiting at the reverse proxy is confirmed separately as part of the Strapi security review. The step is done when legitimate queries succeed, hostile queries are rejected by the depth or result controls, and the server stays responsive after the run.
Promote to staging and production
The platform team moves the code, plugin configuration and permission setup through the deployment pipeline into staging, then production, so each environment runs the same settings. Content is moved separately with Strapi's data transfer tooling, which this sequence does not cover. The team confirms whether introspection stays enabled in production and whether the endpoint is reachable from the public internet through the reverse proxy. The step is done when staging passes the same test set with the same results, and a production smoke test returns expected data for the public role only.
Custom resolvers and policies for business rules Shadow CRUD cannot express
A custom resolver is needed when the answer to a GraphQL query cannot be read straight from one content type. Typical cases include a field that combines Strapi entries with data from an external system, a rule that hides or masks one field for certain roles, or a response shaped for one client, such as a mobile app that needs a single compact object instead of nested relations. Shadow CRUD covers the generic create, read, update and delete operations for each content type, so custom work should start only when a query genuinely needs logic that the generated schema cannot provide. Before writing one, confirm with your team which requirement it solves, because every custom resolver is code your team owns for the life of the project.
The main risk is authorization. The default GraphQL schema respects the same Users & Permissions role settings as the REST routes, but a hand-written resolver that calls the Document Service directly, or that uses a query engine call, can return data the role was never meant to see. Each custom resolver must enforce the same authorization as the REST route for the same data, and policies are the Strapi mechanism for that check. Attach a policy to the resolver so it runs before the handler, and make the policy decide access on the user, role and requested fields. Confirm in the current Strapi GraphQL documentation how resolver-level policies are registered in your project version, since the attachment method differs from REST route configuration.
Test the resolver against the permissions the default schema already respects. For each role, run the same logical query through the Shadow CRUD field and through the custom resolver, then compare the returned fields, the item counts and the behavior for unauthenticated requests. Include draft versus published content, relations to restricted types and any field you intend to hide or mask. Add these checks to CI so a permission change in Users & Permissions fails the build when a custom resolver drifts. Also check that custom resolvers respect the depth and result limits you set for the schema, because a resolver that bypasses them reopens the denial-of-service risk those limits exist to close.
Security controls to review before a GraphQL endpoint goes public
A public GraphQL endpoint exposes the same content as your REST API through a flexible query language, so the attack surface changes shape. The cards below cover the controls that limit query cost, hide schema detail, scope public access, protect custom resolvers, handle tokens and keep a record of expensive queries, with a check for each.
Query depth and result limits
Nested queries can request relations several levels deep and very large result sets, which can exhaust CPU and memory. Depth and result limits are off by default, so they must be set on purpose in the GraphQL plugin configuration. Check by sending a deeply nested query and an unbounded list request from an unauthenticated client against a staging instance, and confirm the server rejects or truncates both. Record the limit values in the review so they survive future schema changes.
Strapi docsIntrospection exposure
Introspection lets any client download the full schema, including type names, fields and relations that may reveal internal models. Decide whether introspection is needed for public clients or only for your development tools, and disable it for production if it is not. Check by running an introspection query against the public URL from outside your network and confirm the response is refused. Repeat the check after every content-type change, since new fields appear in the schema automatically.
Public permissions on generated fields
Shadow CRUD generates queries and mutations for every content type that the Users and Permissions plugin allows, so a public role can read fields you never meant to expose. Review the public role field by field for each generated query and mutation, and remove create, update and delete rights from anonymous users. Check by querying draft-only or internal fields as an anonymous client and confirm each one returns an authorization error or no data.
Authorization in custom resolvers
Custom resolvers bypass the default generated logic, so a resolver that returns data without calling the same permission checks opens a gap that generated fields would have closed. Add a policy or an explicit check inside every custom resolver that reads or writes data, and test it with a role that should be denied. Check by calling each custom query and mutation as a low-privilege user and as an anonymous client, and confirm that the results match the permissions on the underlying content types.
Token handling for authenticated clients
Clients that call the endpoint with a bearer token need short-lived tokens with scopes matched to read-only or write needs. Store tokens in a secrets manager on the client side and never place them in front-end bundles that visitors can download. Check by using an expired or revoked token and a read-only token against a write mutation, and confirm both requests are refused. Confirm your token lifetime and revocation process with your team before go-live.
Logging and monitoring of query cost
Without logs, a slow or abusive query looks like normal traffic. Record operation names, response times and the client or IP for queries that approach the depth and result limits, and alert when that volume grows. Check by sending a query that crosses a limit and confirming it appears in your logs and triggers the alert. Audit logs in Strapi track admin actions only, so API query logging must come from your reverse proxy or application logging layer. Confirm retention with your compliance team.
Questions teams ask before exposing Strapi over GraphQL
What drives the effort of a Strapi GraphQL build?
The effort is driven mainly by how many content types you expose, how much of the schema you customize, and how many access rules you need. Shadow CRUD can generate a working schema from your content types with little hand work, but every content type you expose still needs a decision about which operations, fields and relations editors and consumers may reach. Custom resolvers, custom policies and client-specific query shapes add design and test work on top. Ask any partner to split the quote into schema design, resolver and policy work, permission mapping, depth and complexity limits, testing and handover, so you can see which parts scale with your content model.
Can our team configure Strapi GraphQL without outside help?
Yes, a team with Strapi and Node.js experience can enable the official GraphQL plugin, review the generated schema and set permissions for public and authenticated roles. The harder part is the review that follows: checking which types, fields and filters are reachable by anonymous users, setting depth and result limits that are off by default, and load testing the queries your front end actually sends. Teams without an internal security reviewer or load testing practice usually benefit from a second pair of eyes at that stage. Confirm the exact configuration keys and defaults against the version you run before you change production settings.
How long do review and load testing take for a larger schema?
Review and load testing grow with the number of content types, relations, components and custom resolvers, because each one adds query paths that need checking. A schema with a few content types and public read access is a smaller review than one with dozens of related types, dynamic zones and authenticated write mutations. The sources supplied for this page do not give a duration, so ask for the timeline in writing against your schema inventory. A useful quote lists the number of content types in scope, the roles that query the API, the expected query shapes and the environments available for testing.
What does the work need from our developers and security reviewers?
Your Strapi developers need to provide the content model, the list of front-end queries or clients, and access to a staging instance with production-like data volume. Your security reviewers need to define who may read which content, which mutations are allowed and what logging and rate limits your policy requires. Developers also need time to review generated types and to agree how resolvers and policies are reviewed and merged. Plan these reviews as named tasks with owners, because access rule decisions are often the slowest part of the engagement.
Does exposing GraphQL require a Strapi plan change?
GraphQL is included in every self-hosted Strapi plan. The pricing page lists Community, Growth and Enterprise, and states that all of them include REST and GraphQL APIs, so the API itself does not force an upgrade. Plan choice depends on other features you may need, such as SSO for admin login, which is an add-on for Growth and included in Enterprise, or audit logs and review workflows, which are Enterprise features. Confirm current plan contents on the Strapi self-hosted pricing page before deciding.
What recurring costs follow a GraphQL launch?
Most of the cost is one-time design, build and review, but some work recurs. Every new content type, field or custom resolver changes the schema, so it needs review, testing and permission updates. Strapi minor releases ship often, so you will need to test the GraphQL schema and queries after upgrades. Load and depth limits also need tuning as client queries change. Ask for a quote that separates the initial build from an optional retainer for upgrades and continuous testing, and state which items you expect to handle in house.
What goes wrong when depth and result limits are skipped?
Without limits, a client can send deeply nested or very large queries that consume database and CPU resources, which can lead to denial of service. Strapi leaves depth and result limits off by default, so you must set them deliberately for your content model and your largest legitimate queries. The consequence of getting this wrong is an API that slows or fails under a single crafted request. Test the limits against your real front-end queries first, because a limit that is too strict breaks pages that worked before.
Limits to confirm in your own environment
The GraphQL endpoint is only as safe as the limits set on it, and those limits, their defaults and their interactions depend on your Strapi version, plan and hosting. The items below are what to confirm against the vendor documentation and your own load tests before you expose the endpoint to clients or the public.
Depth and result limit keys
Confirm the exact configuration keys, their defaults and their units for your Strapi version in the GraphQL plugin configuration. Limits that are off by default must be set explicitly in every environment, including staging, so that a test passes under the same rules production enforces. Record the values in version control next to the plugin configuration so a later upgrade cannot quietly remove them.
Strapi v5 migration docsNested relations and components
Depth limits count levels of nesting, but a single shallow query can still fan out across many relations, components and dynamic zone blocks. Test a query that pulls related entries and components at the deepest level your front end needs, then measure response size and resolver time. Pay attention to lists nested inside lists, since result counts multiply at each level.
Node.js and database fit
Check that your Node.js runtime is an Active or Maintenance LTS release and that your database is one Strapi 5 supports, with the minimum versions listed in the installation docs. A GraphQL endpoint running on an unsupported runtime is hard to justify in a security review. Confirm the plan that covers GraphQL and any add-ons you need, such as SSO or audit logs, against the current pricing page before you commit.
Installation requirementsREST and GraphQL responses after migration
If you are moving from Strapi 4, confirm how GraphQL responses and field names change under Strapi 5 before you rewrite client queries. The Document Service API replaced the Entity Service API, and the response format changed, so a compatibility header may help during migration. Test every query your clients send, because a schema difference can break a front end without any server error.
- Compatibility header format
- v4
Endpoint behavior under expected load
Run load tests that match your real client mix, including anonymous public queries, authenticated queries and heavy list views, against the depth and result limits you configured. Measure response time, memory, database connections and error rates as well as the rejections your limits produce. Confirm with your hosting team how rate limits and reverse proxy timeouts interact with long GraphQL queries.
How DeployOpen scopes and delivers a Strapi GraphQL API
DeployOpen starts by agreeing in writing which content types, relations and operations the GraphQL schema should expose, then builds, tests and documents the API inside your own infrastructure. Each step produces evidence your security and platform teams can review before the API reaches production.
How we scope
- We list the content types and fields to expose, and decide which stay out of the GraphQL schema entirely.
- We define which roles and public visitors may read, create or update each type, and record those decisions in the written scope.
- We agree depth limit and result limit values for your query patterns, and confirm the settings in your Strapi version before work starts.
How we build
- We enable the GraphQL plugin, review the Shadow CRUD schema it generates, and extend it only where your queries need more.
- We write custom resolvers and policies for business rules, then test that each role sees only the fields and records it should.
- We test query cost against nested and oversized requests, so denial of service controls are verified rather than assumed.
How we hand over
- We deliver the schema documentation, the list of exposed types and operations, and the configuration values with their reasons.
- We provide test cases for permissions, depth and result limits, and a record of the retest results after fixes.
- We walk your engineers through the resolver code, the policy design and the steps to change the schema safely later.
How we support
- Ongoing support, Strapi upgrades and continuous security testing are available as retainers after handover.
- We can review schema changes and new content types against the agreed limits before they reach production.
- Retainer scope, response expectations and upgrade work are set in writing, and a quote follows from the agreed scope.

