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 }),
}),
Thank you very much for saving me from being stuck!