Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0-beta.1: Mutations without fields not generated correctly #357

Closed
bcksl opened this issue Feb 12, 2023 · 1 comment
Closed

2.0.0-beta.1: Mutations without fields not generated correctly #357

bcksl opened this issue Feb 12, 2023 · 1 comment
Labels
community Something initiated by the community duplicate This issue or pull request already exists

Comments

@bcksl
Copy link

bcksl commented Feb 12, 2023

The generator becomes unhappy about relation tables without additional params. Completely possible that this is expected behaviour but I don't believe the GraphQL spec requires mutations to have args. That said, the mutation should probably just not be generated.

Doesn't work:

model UsersPosts {
  user   User @relation(fields: [userId], references: [id])
  userId Int
  post   Post @relation(fields: [postId], references: [id])
  postId Int

  @@id([postId, userId])
}
/home/bcksl/repo/tgql-demo/node_modules/type-graphql/dist/schema/schema-generator.js:20
                throw new errors_1.GeneratingSchemaError(errors);
                      ^
GeneratingSchemaError: Some errors occurred while generating GraphQL schema:
  Input Object type UsersPostsUpdateManyMutationInput must define one or more fields.
Please check the `details` property of the error to get more detailed info.
    at Function.generateFromMetadata (/home/bcksl/repo/tgql-demo/node_modules/type-graphql/dist/schema/schema-generator.js:20:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async buildSchema (/home/bcksl/repo/tgql-demo/node_modules/type-graphql/dist/utils/buildSchema.js:11:20)
    at async /home/bcksl/repo/tgql-demo/src/index.ts:31:18 {
  details: [
    GraphQLError: Input Object type UsersPostsUpdateManyMutationInput must define one or more fields.
        at SchemaValidationContext.reportError (/home/bcksl/repo/tgql-demo/node_modules/graphql/type/validate.js:73:7)
        at validateInputFields (/home/bcksl/repo/tgql-demo/node_modules/graphql/type/validate.js:532:13)
        at validateTypes (/home/bcksl/repo/tgql-demo/node_modules/graphql/type/validate.js:260:7)
        at validateSchema (/home/bcksl/repo/tgql-demo/node_modules/graphql/type/validate.js:43:3)
        at graphqlImpl (/home/bcksl/repo/tgql-demo/node_modules/graphql/graphql.js:60:63)
        at /home/bcksl/repo/tgql-demo/node_modules/graphql/graphql.js:23:43
        at new Promise (<anonymous>)
        at graphql (/home/bcksl/repo/tgql-demo/node_modules/graphql/graphql.js:23:10)
        at Function.generateFromMetadata (/home/bcksl/repo/tgql-demo/node_modules/type-graphql/dist/schema/schema-generator.js:18:60)
        at buildSchema (/home/bcksl/repo/tgql-demo/node_modules/type-graphql/dist/utils/buildSchema.js:11:61) {
      path: undefined,
      locations: undefined,
      extensions: [Object: null prototype] {}
    }
  ]
}

Works:

model UsersPosts {
  user   User @relation(fields: [userId], references: [id])
  userId Int
  post   Post @relation(fields: [postId], references: [id])
  postId Int
  unused Int

  @@id([postId, userId])
}
  • Node v16.19.0
  • typegraphql-prisma version 2.0.0-beta.1
  • Prisma version 4.10.1
  • TypeScript version 4.9.5
@MichalLytek
Copy link
Owner

Duplicate of #19 🔒

@MichalLytek MichalLytek added duplicate This issue or pull request already exists community Something initiated by the community labels Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Something initiated by the community duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants