plugin-graphql
plugin-graphql copied to clipboard
More adapter customization
Nice project, but how to customize adapter for handle more complex schemas :
- The argument name for input in mutations (in mode type) is not necessarily identical to the name of modeltype. Can the adapter handle this? In my case, the name of the arguments is always "values" ...
- InputType for mutations can be different by mutations (update != create). And it's not necessarily the type of complete model : It can be a partial model for update mutation (see my schema example below).
type MyModel {
id: ID!
requireProp: Int!
optionalProp: String
}
input MyModelMutationCreate { ### ID is not provided because it was generated server side
requireProp: Int!
optionalProp: String
}
input MyModelMutationUpdate { ### All fields are not required... if a field is not provided, it's ignored (when persisted : null !== undefined)
requireProp: Int ### requiredProp is optional here because we can update only other properties
optionalProp: String
}
type Mutation {
### Argument name is not myModel, but "values" and type is not MyModel
createMyModel(
values: MyModelMutationCreate!
): MyModelReturnMutation
### Argument: name is not myModel, but "values" and type is not MyModel
updateMyModel(
id: ID!
values: MyModelMutationUpdate!
): MyModelReturnMutation
deleteMyModel(
id: ID!
): MyModelReturnMutation
### The return type for mutations not return MyModel directly but wrap it like this
type MyModelReturnMutation {
node: MyModel
error: String # return null if mutation successfull or error...
}
Thank you for your feedback.
This kind of plugin has naturally some requirements to the schema. However I'm open for customization options. I don't have any time to work on this plugin currently. But feel free to create a PR, I will take care of it as soon as possible.