Skip to content

Instantly share code, notes, and snippets.

@sangdth
Last active October 18, 2021 12:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sangdth/111c76317353582e78e7c331c404f955 to your computer and use it in GitHub Desktop.
Save sangdth/111c76317353582e78e7c331c404f955 to your computer and use it in GitHub Desktop.
Google App Engine problem with read-only file system error

If you are using type-graphql in your project, and trying to deploy to Google App Engine, you probably will encounter the read-only file system error: Error: EROFS: read-only file system, open './src/schema.gql'

This is because Google App Engine has quite different way to handle file system: https://cloud.google.com/appengine/docs/standard/python3/using-temp-files

In my Nestjs app, I'm using @nestjs/graphql module wrapper, in which automatic generate schema.gql file at /src folder by default, and Google App Engine allows only /tmp folder.

Fortunately, we can customise the path: https://github.com/MichalLytek/type-graphql/blob/master/docs/emit-schema.md

With a simple check and voila, it works!

    GraphQLModule.forRoot({
      debug: false,
      playground: true,
      typePaths: ['./**/*.gql'],
      autoSchemaFile: !process.env.GAE_ENV
        ? './src/schema.gql' : '/tmp/schema.gql',
      context: ({ req }) => ({ req }),
    }),

@Masaokb
Copy link

Masaokb commented Mar 17, 2021

Thank you very much for saving me from being stuck!

@sangdth
Copy link
Author

sangdth commented May 25, 2021

Glad it helps, @Masaokb

@ugglr
Copy link

ugglr commented Sep 7, 2021

This helped me too! Thank you 🤩

@Nayir
Copy link

Nayir commented Oct 18, 2021

Thank you so much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment