Import GraphQL files from other GraphQL files (closes #1477)#1892
Merged
DeMoorJasper merged 2 commits intoAug 14, 2018
Conversation
DeMoorJasper
requested changes
Aug 13, 2018
| const Asset = require('../Asset'); | ||
| const localRequire = require('../utils/localRequire'); | ||
| const Resolver = require('../Resolver'); | ||
| const fs = require('../utils/fs'); |
Member
There was a problem hiding this comment.
Please use parcels fs util
Member
There was a problem hiding this comment.
Damn, not sure why I thought it wasn't
|
|
||
| await Promise.all( | ||
| code | ||
| .split(os.EOL) |
Member
There was a problem hiding this comment.
Will this work in every case?
Seems like this would not work if a user clones a repo that is being used developed various OSes
Author
There was a problem hiding this comment.
Good point, using a regex such as /\r?\n/ is probably more resilient.
Author
There was a problem hiding this comment.
Changed it to use /\r\n?|\n which is pretty much the same as what the GraphQL specification defines as a line terminator
DeMoorJasper
approved these changes
Aug 14, 2018
devongovett
pushed a commit
that referenced
this pull request
Oct 15, 2018
An alternative to #1817 that doesn't rely on using `graphql-tag/loader`, which is a Webpack loader. #### What this does: 1. Recursively traverse the GraphQL files. 2. Collect all the imports into a map. 3. Concatenate them. 4. Parse the result into an AST. #### What this doesn't do: This PR (as of time of writing) does not have feature parity with `graphql-tag/loader`, meaning that: * It does not de-duplicate fragments that have the same name. _This is a behavior that I personally disapprove of since it can lead to surprising results instead of throwing an error if a user accidentally (however unlikely) reuses an already defined fragment name._ * It does not collect multiple defined queries/mutations and make them individually require-able from a JavaScript parent. If the above behaviours are desired then I can implement them.
devongovett
pushed a commit
that referenced
this pull request
Oct 15, 2018
An alternative to #1817 that doesn't rely on using `graphql-tag/loader`, which is a Webpack loader. #### What this does: 1. Recursively traverse the GraphQL files. 2. Collect all the imports into a map. 3. Concatenate them. 4. Parse the result into an AST. #### What this doesn't do: This PR (as of time of writing) does not have feature parity with `graphql-tag/loader`, meaning that: * It does not de-duplicate fragments that have the same name. _This is a behavior that I personally disapprove of since it can lead to surprising results instead of throwing an error if a user accidentally (however unlikely) reuses an already defined fragment name._ * It does not collect multiple defined queries/mutations and make them individually require-able from a JavaScript parent. If the above behaviours are desired then I can implement them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An alternative to #1817 that doesn't rely on using
graphql-tag/loader, which is a Webpack loader.What this does:
What this doesn't do:
This PR (as of time of writing) does not have feature parity with
graphql-tag/loader, meaning that:If the above behaviours are desired then I can implement them.