Require functionality better than @GraphQLIgnore #1223
Replies: 2 comments 9 replies
-
In theory, yes it would be possible with our schema generator to have this behaviour but that goes against the GraphQL spec. For comparison can you do this exercise for me: How would you represent your desired schema in SDL? type Query {
findEntityA: [EntityA]
}
type Mutation {
saveEntityA(input: EntityAInput): Boolean
}
input EntityAInput {
id: UUID
name: String
content: EntityAContentInput
}
# How do we have two types called "EntityAContentInput" that have different fields?
input EntityAContentInput {
primaryEntityBId: UUID
secondaryEntityBIds: [UUID]
}
# How do we have two types called "EntityAContent" that have different fields?
type EntityAContent {
primaryEntityBId: UUID
secondaryEntityBIds: [UUID]
primaryEntitiyB: EntityB
seondaryEntitiyBs: [EntityB]
} |
Beta Was this translation helpful? Give feedback.
-
Hello 👋 Kotlin enforces null safety at compile time so when you initialize your properties you have to explicitly provide values (unless using
It is not possible to initialize If you have different requirements for your queries and mutations (or in your case it sounds like it is a difference between input and ouput types) -> just create separate types instead. |
Beta Was this translation helpful? Give feedback.
-
This is a case that shows why "@GraphQLIgnore" is not enough
Postgres supports JSONB, like this
The table entity_a has a column whose type is JSONB, many SQL frameworks(such as JOOQ) can map it to a java/kotlin type easily, That JSONB type is mapped to this type
Then declare the Graph object type for "entity_a", it is used as the return type of query methods
Then declare the graphql input type for "entity_a", it will be used as the parameter type of mutation methods.
"EntityAContent" is shared by both query and mutations, graphql-kotlin uses it to generate schema twice, both object type and input type will be generated with similar code
Ok, let's improve EntityAContent
Finally, for the common type shared by both query and mutation.
Is it possible to support "@GraphQLIngore(IngoreMode.ONLY_FOR_QUERY)"?
Beta Was this translation helpful? Give feedback.
All reactions