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

Feature Request: Support for more granular @gql directives (for nested models) #171

Open
StephanDecker opened this issue Jan 11, 2024 · 0 comments
Labels
is: feature request New feature request package: generator Generator package

Comments

@StephanDecker
Copy link

It's only a feature request that would tidy up the generated graphql schema for deeply nested prisma models (depending on individual use cases). I am aware of the shield and the hooks properties in order to control access - but sometimes it would be helpful to consider this during the schema generation already in order to have a more lightweight schema.
It's some kind of follow-up of this issue: #111
Let's give me an example:

model ExampleTable {
    id       String     @id @default(uuid())
    name     String
    refTable RefTable[]
}

model RefTable {
    id             String       @id @default(uuid())
    name           String
    exampleTable   ExampleTable @relation(fields: [exampleTableId], references: [id])
    exampleTableId String
}

Currently the following two requests can't be handled:

  1. The user should be able to create a RefTable record when using the ExampleTable model but not when using the RefTable model directly.

Example implementation:

/// @gql(fields: { refTable: {create: true}})
model ExampleTable {
    id       String     @id @default(uuid())
    name     String
    refTable RefTable[]
}

/// @gql(mutations: { create:null})
model RefTable {
    id             String       @id @default(uuid())
    name           String
    exampleTable   ExampleTable @relation(fields: [exampleTableId], references: [id])
    exampleTableId String
}
  1. The user should be able to create a RefTable record only by using the RefTable model directly but not when using the ExampleTable model.

Example implementation:

/// @gql(fields: { refTable: {create: null}})
model ExampleTable {
    id       String     @id @default(uuid())
    name     String
    refTable RefTable[]
}

model RefTable {
    id             String       @id @default(uuid())
    name           String
    exampleTable   ExampleTable @relation(fields: [exampleTableId], references: [id])
    exampleTableId String
}

What do you think? Could you put it on the roadmap?

@maoosi maoosi added is: feature request New feature request package: generator Generator package labels Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: feature request New feature request package: generator Generator package
Projects
None yet
Development

No branches or pull requests

2 participants