-
Notifications
You must be signed in to change notification settings - Fork 685
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
[PWA-1658] Move graphql-cli-validate-magento-pwa-queries to @magento scope #3198
Changes from 4 commits
fa7a5b0
f8a6f42
063b1bc
f005420
2b15e9a
99068e6
74243f0
4252a9a
5f025c7
b9de346
0f56922
52ed88d
f94d9dc
5b7fd9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
projects: | ||
default: | ||
schema: | ||
- ${MAGENTO_BACKEND_URL}/graphql | ||
- "**/client-schema.graphql" | ||
documents: | ||
- '../{peregrine,venia-ui,venia-concept}/{lib,src}/**/!(*.spec).js' | ||
- '!**/*.ce.js' | ||
extensions: | ||
codegen: | ||
generates: | ||
./merged-schema.v4.json: | ||
plugins: | ||
- introspection |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extend type Query { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind throwing a comment block above explaining who/what this file is for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For sure 👍 intend to collocate these closer to where they are defined, similar to what I did with the checkmo extension. |
||
customerWishlistProducts: [String!]! | ||
} | ||
|
||
extend type Cart { | ||
include_gift_receipt: Boolean! | ||
include_printed_card: Boolean! | ||
isBillingAddressSame: Boolean! | ||
local_gift_message: String | ||
paymentNonce: String | ||
} | ||
|
||
extend type Currency { | ||
current_currency_code: String! | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,15 @@ | |
"build:report": "buildpack generate-build-report", | ||
"buildpack": "buildpack", | ||
"clean": "rimraf dist", | ||
"download-schema": "graphql get-schema --project venia --insecure", | ||
"download-schema": "graphql-codegen --require dotenv/config", | ||
"lint": "eslint --ignore-path .gitignore 'src/**/{*.js,package.json}'", | ||
"prettier": "prettier --loglevel warn --ignore-path .gitignore 'src/**/*.@(css|graphql|js)' '*.js'", | ||
"prettier:check": "yarn run -s prettier -- --check", | ||
"prettier:fix": "yarn run -s prettier -- --write", | ||
"start": "buildpack serve .", | ||
"start:debug": "node --inspect-brk ./node_modules/.bin/webpack-dev-server --progress --color --env.mode development", | ||
"test": "yarn run -s prettier:check && yarn run -s lint && jest", | ||
"validate-queries": "yarn run download-schema && graphql validate-magento-pwa-queries --project venia", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Also how will folks validate their queries in their scaffolded apps without this script/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the fileglob that was previously in
edit - But yes, this would cause breakage in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure that
So while we may not validate any queries at least grapqhl schema needs to generate successfully (funnily we have had a case where the back-end schema did not work but all other queries did). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fooman - This was a tiny reason why I left the Ideal state is that validation works in scaffolded apps the same as the monorepo, and the state in this PR is no validation. We do introspection at build time for fragment matching, so I'm not sure a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for getting back to me. Can confirm that latest scaffolded is not working well with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With quite a bit of tinkering I am now able to run validate-queries locally in a scaffolded apps. In rough steps (I am not running the same apollo version which may be the reason for step 1):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fooman |
||
"validate-queries": "graphql validate --apollo --keepClientFields --noStrictFragments --require dotenv/config", | ||
"watch": "webpack-dev-server --progress --color --env.mode development" | ||
}, | ||
"repository": "github:magento/pwa-studio", | ||
|
@@ -51,6 +51,9 @@ | |
"@babel/plugin-transform-runtime": "~7.4.4", | ||
"@babel/preset-env": "~7.3.4", | ||
"@babel/runtime": "~7.4.2", | ||
"@graphql-cli/codegen": "~1.17.23", | ||
"@graphql-cli/validate": "~2.1.0", | ||
"@graphql-codegen/introspection": "~1.18.2", | ||
"@magento/babel-preset-peregrine": "~1.1.0", | ||
"@magento/eslint-config": "~1.5.0", | ||
"@magento/pagebuilder": "~5.0.0", | ||
|
@@ -85,8 +88,8 @@ | |
"express": "~4.16.4", | ||
"file-loader": "~4.0.0", | ||
"graphql": "~15.3.0", | ||
"graphql-cli": "~3.0.11", | ||
"graphql-cli-validate-magento-pwa-queries": "~1.4.0", | ||
"graphql-cli": "~4.1.0", | ||
"graphql-config": "~3.3.0", | ||
"html-webpack-plugin": "~3.2.0", | ||
"informed": "~3.27.0", | ||
"jarallax": "~1.11.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,11 @@ import { gql } from '@apollo/client'; | |
*/ | ||
const GET_GIFT_OPTIONS = gql` | ||
query getGiftOptions($cartId: String!) { | ||
cart(cart_id: $cartId) @client { | ||
cart(cart_id: $cartId) { | ||
id | ||
include_gift_receipt | ||
include_printed_card | ||
gift_message | ||
include_gift_receipt @client | ||
include_printed_card @client | ||
local_gift_message @client | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the rename here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I think the original intent behind the message was to actually hook this up :) As is, it doesn't actually do anything which might be surprising. |
||
} | ||
} | ||
`; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,15 +37,16 @@ export const GET_PAYMENT_INFORMATION = gql` | |
} | ||
${AvailablePaymentMethodsFragment} | ||
`; | ||
|
||
// We disable linting for local fields because there is no way to add them to | ||
// the fetched schema. | ||
// https://github.com/apollographql/eslint-plugin-graphql/issues/99 | ||
/* eslint-disable graphql/template-strings */ | ||
export const GET_PAYMENT_NONCE = gql` | ||
query getPaymentNonce($cartId: String!) { | ||
cart(cart_id: $cartId) @client { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In many of the queries we move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the fetchPolicy was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted these directive changes in b9de346 |
||
cart(cart_id: $cartId) { | ||
id | ||
paymentNonce | ||
paymentNonce @client | ||
} | ||
} | ||
`; | ||
|
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.
v3
?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.
Config structure for
graphql-config@3