For two of my GraphQL mutations, I want to have my create and update functions use the same input parameters, but update with an additional "id" field. I strongly believe in "don't repeat yourself", so I would like to create one dict or class that they can both use/inherit, and be able to add the "id" to the update function. If I decide to add new parameters, I want both mutations to be affected with minimal code updates.
I tried a few things, but none worked. After looking at the code, I saw that there was a simple fix that would allow me to use a dictionary and be able to do this:
```UserParameters = {
"name": graphene.String(),
"email": graphene.String(),
...
}
UserCreate(graphene.Mutation):
Arguments = {
**UserParameters,
"password": graphene.String()
}
...
UserUpdate(graphene.Mutation):
Arguments = {
**UserParameters,
"id": graphene.ID(required=True)
}
...
```
I don't know if there was another way to achieve this result with the current method of creating the argument inputs.
If anyone has a more Pythonic or elegant way to achieve this result, I'm open to ideas.
"Hash" in the Python world implies a cryptographic hash, or possibly a checksum. Here, I believe "hash" is being used to mean "hash map", which would be more commonly known in Python as a dictionary, or dict for short.
With the current documentation, I get after execution:
"graphql.error.located_error.GraphQLLocatedError: name 'context' is not defined"
I don't get any error after the correction I made (I haven't yet tried to upload a file…)
I have a project still in 1.2.0 thats has been broken in my last release since it used `'graphql-core>=1.0.1'` in the `install_requires`. Since `graphql-core` has released version 2.0 with breaking changes and there was no instruction to maintain version 1, it was included as a dependency. This prevents this situation for the future.