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

fix mutation name #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix mutation name #15

wants to merge 2 commits into from

Conversation

msayagh
Copy link

@msayagh msayagh commented Apr 20, 2019

Mutations were previously found using the keyword "GraphQLMutation", while users do not always follow this rule. They can, however, follow this pattern:

extend type Mutation {
users: UserMutation
}

type UserMutation {
createUsers(email: String): User
}

This pull request fixes that problem. I first find what are the mutations that we have, then run the previously implemented analysis

@coveralls
Copy link

Coverage Status

Coverage decreased (-4.6%) to 93.072% when pulling 8afb3f8 on msayagh:master into 3a6c4e6 on happylinks:master.

Copy link
Owner

@happylinks happylinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @msayagh, thanks for the PR! Looks like a good improvement. I have some comments that would help us land this in the next release. Let me know if something is unclear :)

Kind regards,
Michiel Westerbeek

@@ -2,7 +2,12 @@
"name": "gqlint",
"version": "1.8.0",
"description": "GraphQL Linter",
"keywords": ["graphql", "gql", "lint", "linter"],
"keywords": [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the changes from this file? They're not related to your pr.

@@ -1,6 +1,6 @@
{
"name": "gqlint",
"version": "1.6.1",
"version": "1.8.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase on master (git pull --rebase origin master) as I don't think you have the latest code. I'll do the bumping :)

@@ -58,12 +58,43 @@ const checkWrongName = (text, node, messages, name) => {
}
};

function getMutationNames(ast) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you place this function in a new file in the "lib" folder, maybe helpers.js or mutations.js, whatever you think is best.
It's now duplicated in two places and if we are gonna have more rules for mutations we should probably use this there as well.

visit(ast, {
ObjectTypeDefinition(node) {
if (node.name.value !== 'GraphQLMutation') {
if (mutationNames.indexOf(node.name.value) < 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And lastly, would you be able to add a test for this new "extend type Mutation" in https://github.com/happylinks/gqlint/blob/master/tests/rules/removedelete.mutations.test.js and maybe also in https://github.com/happylinks/gqlint/blob/master/tests/rules/singular.mutations.test.js just to be sure.

@msayagh
Copy link
Author

msayagh commented Apr 23, 2019

Sure, I will address your comments ASAP.

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

Successfully merging this pull request may close these issues.

3 participants