[V4] GraphQL type definitions are not generated


the V3 strapi is generating a graphql schema ( ./exports/graphql/schema.graphql). We use this to publish this subgraph to our apollo studio. In the current v4 version no export file is generated. Is that intended?

If so, is there a way to generate this scheme somehow differently?

I tested this in a fresh strapi installation.


GraphQL Config
  graphql: {
    endpoint: '/graphql',
    shadowCRUD: true,
    playgroundAlways: false,
    depthLimit: 7,
    amountLimit: 100,
    apolloServer: {
      tracing: false,
System Information
  • Strapi Version: 4.0.0
  • Operating System: ubuntu
  • Database: postgres
  • Node Version: 14.18.2
  • NPM Version: -
  • Yarn Version: 1.22.5


we have the same problem and it prevents us from migrating on production. It there any solution for this?


Any ideas?

Has no one an solution/answer for this?

I am having same issue… This needs to be solved / answered what we can do ? Without this we can’t generate types for FE and can’t develop


It’s totally possible using the strapi.plugin('graphql').service('extension'), you have an example in the user and permission plugin:

  1. https://github.com/strapi/strapi/blob/master/packages/plugins/users-permissions/server/register.js#L8-L10
  2. https://github.com/strapi/strapi/blob/master/packages/plugins/users-permissions/server/graphql/index.js#L10

Here is the related documentation: GraphQL - Strapi Developer Docs

But before getting deeper with GraphQL I recommend you to check this post before: Discussion regarding the complex response structure for REST & GraphQL (Developer Experience)

Hope this help!

I’m not sure if there is another (better) way, but if you edit @strapi/plugin-graphql directly you can generate types following instructions from the Nexus docs.

The Strapi team have mentioned using patch-package as an option for making these sorts of changes permanent without having to fork the project.

In this file:

Add the following:

const path = require('path')

// ------ other stuff--------//

// Amend the makeSchema function (which starts on line 88) by adding shouldGenerateArtifacts & locations for generated type files.

    const nexusSchema = makeSchema({
      types: [
        // Add the auto-generated Nexus types (shadow CRUD)
        // Add every Nexus type registered using the extension service

      plugins: [
        // Add every plugin registered using the extension service
      shouldGenerateArtifacts: process.env.NODE_ENV === 'development',
      outputs: {
        schema: path.join(__dirname, 'generated/schema.gen.graphql'),
        typegen: path.join(__dirname, 'generated/nexusTypes.gen.ts'),

I am not certain whether this is what you are looking for as I don’t use Apollo Studio and have been using introspection with client-side Apollo instead.

thanks for the reply. I will test this solution.

I hope the export feature comes back in the @strapi/plugin-graphql plugin. For now i created my own plugin to create a schema.graphql file

Would it be possible to share the code with us or like open source it? It would be very helpful for the community. Thanks in advance.

News: I created a feature request for strapi yesterday but someone mentioned, that the graphql plugin is already able to generate the schema file: https://github.com/strapi/strapi/pull/12467

It will be generated in the dist directory when you start the strapi server. But of course you can configure it to be saved outside the dist folder.