-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[chore] Initial attempt at fixing validator for venia-ui #2095
Conversation
|
Signed-off-by: Stephen Rugh <rugh@adobe.com>
969c74c
to
36dfea1
Compare
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
package.json
Outdated
@@ -90,7 +90,7 @@ | |||
}, | |||
"husky": { | |||
"hooks": { | |||
"pre-push": "yarn run prettier:check && yarn run lint" | |||
"pre-push": "yarn run prettier:check && yarn run lint && yarn run validate-queries" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debatable. Do we want to run this on push? I think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, we don't currently. I'm okay with adding it since I always push with --no-verify
anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ask the team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpatil-magento can we add this script to the CI checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://jira.corp.magento.com/browse/PWA-341 was created -- team says NO to prepush :D
@@ -67,7 +67,7 @@ async function validateQueries(context, argv) { | |||
|
|||
// Validate our queries against that schema. | |||
context.spinner.start('Finding queries in files...'); | |||
const validator = getValidator({ clients, project }); | |||
const validator = getValidator({ clients, project, schemaPath }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the validator will run the schema stored in the path rather than doing a "magical" search for the file within the directory the script is running. Basically we can run this from venia-concept but still check files in the sibling package, venia-ui.
})); | ||
|
||
const ruleDefinition = ['error', ...clientRules]; | ||
const ruleDefinition = ['warn', ...clientRules]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debatable. I know some folks think warnings are code smells. If we want to leave this as error
we should then fix all the issues in the current graphql files (see the screenshot in the PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in this repo, we do prefer errors over warnings. That said, if you'd like to create an issue to fix all the warnings (and then flip it back from warn
to error
), that would be fine.
Signed-off-by: Stephen Rugh <rugh@adobe.com>
@@ -8,7 +8,7 @@ | |||
}, | |||
"validate-magento-pwa-queries": { | |||
"clients": ["apollo", "literal"], | |||
"filesGlob": "src/**/*.{js,graphql,gql}" | |||
"filesGlob": "../{venia-ui,venia-concept}/{lib,src}/**/**/*.{js,graphql,gql}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm bad with patterns...do I need the extra /**
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you do.
I will fix tests once we land on a consensus for the debatable bits. |
package.json
Outdated
@@ -90,7 +90,7 @@ | |||
}, | |||
"husky": { | |||
"hooks": { | |||
"pre-push": "yarn run prettier:check && yarn run lint" | |||
"pre-push": "yarn run prettier:check && yarn run lint && yarn run validate-queries" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, we don't currently. I'm okay with adding it since I always push with --no-verify
anyway.
@@ -8,7 +8,7 @@ | |||
}, | |||
"validate-magento-pwa-queries": { | |||
"clients": ["apollo", "literal"], | |||
"filesGlob": "src/**/*.{js,graphql,gql}" | |||
"filesGlob": "../{venia-ui,venia-concept}/{lib,src}/**/**/*.{js,graphql,gql}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you do.
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
7961316
to
567be69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. Curious to see QA's take.
})); | ||
|
||
const ruleDefinition = ['error', ...clientRules]; | ||
const ruleDefinition = ['warn', ...clientRules]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in this repo, we do prefer errors over warnings. That said, if you'd like to create an issue to fix all the warnings (and then flip it back from warn
to error
), that would be fine.
Signed-off-by: Stephen Rugh <rugh@adobe.com>
...clients.map(clientName => ({ | ||
env: clientName, | ||
schemaJsonFilepath: schemaPath, | ||
requiredFields: ['id'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Required Fields rule validates that any specified required field is part of the query, but only if that field is available in schema. This is useful to ensure that query results are cached properly in the client.
https://github.com/apollographql/eslint-plugin-graphql#required-fields-validation-rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpatil-magento Theoretically, all of these id
additions to the queries should make them hit the cache better. When you test this branch, let me know if you notice any perceptible difference in query performance.
@jimbo Don't see any performance degradation on this PR, so merging this one. |
Description
yarn run validate-queries
was incomplete. It only validatedvenia-concept
which no longer has any any graphql. That's not to say it won't always, but we should at least have had the validator checkvenia-ui
.Note: I added the validator to
pre-push
but I also changed the errors to warnings so as to not kill the push. We can discuss in this PR.Related Issue
Closes PWA-251
Acceptance
Verification Stakeholders
Ya'll.
Specification
Verification Steps
yarn run validate-queries
. Result should display.Screenshots / Screen Captures (if appropriate)
Checklist