Nexus: Deploying to AWS Lambda

Created on 21 Nov 2019  Â·  4Comments  Â·  Source: graphql-nexus/nexus

I am currently facing an issue whilst deploying to AWS lambda. I have used the nexus-prisma example from the examples directory and deployed using the serverless framework.

After deploying and accessing the playground, this error is logged in Cloudwatch:
EROFS: read-only file system, unlink '/var/task/node_modules/@types/nexus-prisma-typegen/index.d.ts'

image

Do we need to add any separate configuration for lambdas?

Most helpful comment

@ryands17 to prevent this error just pass {shouldGenerateArtifacts: false} in the options you provide to nexusPrismaPlugin(options):

Example:

const schema = makeSchema({
  types: [Query, Mutation, Post, User],
  plugins: [nexusPrismaPlugin({
    shouldGenerateArtifacts: false
  })],
  outputs: {
    schema: __dirname + '/generated/schema.graphql',
    typegen: __dirname + '/generated/nexus.ts',
  },
  typegenAutoConfig: {
    contextType: 'Context.Context',
    sources: [
      {
        source: '@prisma/client',
        alias: 'prisma',
      },
      {
        source: require.resolve('./context'),
        alias: 'Context',
      },
    ],
  },
})

All 4 comments

@ryands17 to prevent this error just pass {shouldGenerateArtifacts: false} in the options you provide to nexusPrismaPlugin(options):

Example:

const schema = makeSchema({
  types: [Query, Mutation, Post, User],
  plugins: [nexusPrismaPlugin({
    shouldGenerateArtifacts: false
  })],
  outputs: {
    schema: __dirname + '/generated/schema.graphql',
    typegen: __dirname + '/generated/nexus.ts',
  },
  typegenAutoConfig: {
    contextType: 'Context.Context',
    sources: [
      {
        source: '@prisma/client',
        alias: 'prisma',
      },
      {
        source: require.resolve('./context'),
        alias: 'Context',
      },
    ],
  },
})

If google has brought you here for this error and the fix above doesn't seem to work, you may wish to ensure the plugin version you're running matches the latest version of the documentation — as of this writing the flag has been moved out of the plugins array, and now appears at the top level of makeSchema:

makeSchema({
  types,
  shouldGenerateArtifacts: process.env.NODE_ENV === 'development'
  ...
})

I had the same error as @ryands17 above, and this configuration tweak allowed me to get past it.

@langer Does this still work with you with nexus 1.0.0? I've tried the same thing, but unfortunately still get the error.

@sreuter now the original is what's working for us:

  plugins: [
    nexusSchemaPrisma({
      shouldGenerateArtifacts: true,
    }),
  ],

EDIT: i was mistaken — just noticed when trying to modify our schema that a new enum wasn't getting an artifact generated. i'm investigating now but it appears to be the case that node_modules/.prisma/client/index.js is being successfully regenerated while node_modules/.prisma/client/index.d.ts is not.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MathiasKandelborg picture MathiasKandelborg  Â·  5Comments

tonyfromundefined picture tonyfromundefined  Â·  3Comments

deadcoder0904 picture deadcoder0904  Â·  3Comments

huv1k picture huv1k  Â·  6Comments

capaj picture capaj  Â·  5Comments