-
Notifications
You must be signed in to change notification settings - Fork 683
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
Bugfix/heuristic fragment matcher #1707
Bugfix/heuristic fragment matcher #1707
Conversation
|
@Jordaneisenburger Wow, this is so valuable! Thanks for tackling this issue; it's been bothering us lately. Let's see if we can't find a way to get the backend URL from |
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 know exactly what it looks like yet but I'd really like to move this build-time logic to buildpack
.
Thanks for tackling this!
I moved this build-time logic to |
@@ -0,0 +1,63 @@ | |||
const fetch = require('node-fetch'); |
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.
So GitHub didn't pick it up, but I renamed fetcherUtils
to graphQL
(and their associated test files).
This is instrumentation to make GraphQL calls so I think this name is more indicative of what this module's job is.
.then(json => json.data) | ||
.catch(err => { | ||
console.error(err); | ||
throw err; |
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.
Note that instead of returning an empty string here we are now re-throwing the caught error.
This allows the caller to determine how they want to handle the error case in a more idiomatic way try / catch
instead of having to check success cases against an empty string.
@@ -0,0 +1,12 @@ | |||
# Introspect the GraphQL schema to obtain information about its types. |
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.
Note that buildpack
now has its own queries
folder with .graphql
files in it.
This allows us to not have to inline large GraphQL strings 🎉
module.exports = { | ||
getMediaUrl, | ||
getSchemaTypes | ||
}; |
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 file isn't strictly necessary, and we'll have to add all new .graphql
files here to make them available for the rest of buildpack
, but we do need to require
the .graphql
files in a different way (using requireGraphQL
) so this consolidates that logic.
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 would prefer that. Having a simple index.js makes things simpler for the future.
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.
Great!
transformIgnorePatterns: ['node_modules/(?!@magento/)'], | ||
globals: { | ||
TEST_GLOBAL: 'true', | ||
UNION_AND_INTERFACE_TYPES: { |
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 PR introduced a dependency on globals in a way that uncovered a bug in our config. The previous location of the globals
configuration did not actually set globals and the test for STORE_NAME
hardcoded it in the test spec rather than relying on the config (probably because it was broken).
This now properly creates serializable globals for Jest.
Description
This PR adds the
IntrospectionFragmentMatcher
to resolve the heuristic fragment matcher warning.It:
DefinePlugin
IntrospectionFragmentMatcher
at run timeAs such, there is also some refactoring of buildpack to make issuing GraphQL requests easier 🎉 .
Related Issue
Related issues #1474 & #1662
Closes #1474
Verification Steps
yarn run build
in project root