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

More adapter customization #124

Open
Dodobibi opened this issue Sep 23, 2019 · 1 comment
Open

More adapter customization #124

Dodobibi opened this issue Sep 23, 2019 · 1 comment

Comments

@Dodobibi
Copy link

Dodobibi commented Sep 23, 2019

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...
}
@phortx
Copy link
Collaborator

phortx commented Sep 24, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants