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

Redundancy between mutators and defaultMutations? #33

Closed
eric-burel opened this issue Apr 26, 2021 · 1 comment · Fixed by #62
Closed

Redundancy between mutators and defaultMutations? #33

eric-burel opened this issue Apr 26, 2021 · 1 comment · Fixed by #62
Assignees
Labels
bug Something isn't working internship

Comments

@eric-burel
Copy link
Collaborator

Describe the bug
We have a function to get the document to update in default mutations, but also in the mutators:

  • packages/graphql/server/resolvers/defaultMutationResolvers.ts (getMutationDocument)
  • packages/graphql/server/resolvers/mutators.ts

Shouldn't we remove the one in the default mutation?

@eric-burel eric-burel added the bug Something isn't working label Apr 26, 2021
@eric-burel
Copy link
Collaborator Author

eric-burel commented Jul 6, 2021

It leads to a bug where useUpdate({input: {id: "foo", data: {...}}}) doesn't work (when specifying id explicitely).

On the example of "update", I think we should do this:

  • remove the check for the document presence in performMutationCheck => that's the responsbility of the mutator
  • remove the call to "getMutationDocument" => that's the responsibility of the mutator as well to check the document existence
  • keep passing either "selector" or "dataId" to the mutator in the mutation

The mutations are there: packages/graphql/server/resolvers/defaultMutationResolvers.ts
The mutator there: packages/graphql/server/resolvers/mutators.ts

The path is like this:
request > mutation > mutator > database

So in the MVC model, mutation is a Controller (it simply checks authorization, convert the input into a data selector, and that's it) and mutator a Model (it communicates more closely with the db, checking document existence and updating it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internship
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants