-
Notifications
You must be signed in to change notification settings - Fork 177
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
External fragments are not pulled into the query document using the loader. #53
Comments
You can use the new import syntax, as in: #import "./UserInfo.gql"
query Users($emails: [String]) {
... Does that help? |
@czert -- Not working - This is run under Angular CLI & Webpack. With no access to modify Webpack's config to add the loader, Webpack errors saying it doesn't know how to load the (fragment) file. Only if the loader could invoke itself to load the fragments recursively, all would work fine. I believe that this line may be the culprit. |
@un33k setting up webpack so that it uses graphql-tag/loader for all *.gql imports should help, i think. |
@czert as I mentioned above, Webpack config is handled by Angular CLI. So at this time, there is no way to pass the loader option to Webpack. |
I think it might be related to this |
@un33k without using the in particular, we have trouble with the case where the webpack loader compiles a graphql document which includes a fragment that we have not yet discovered; there's no way for us to "wait" until the entire tree of modules has been crawled to then fulfill the fragment definition. i had some thoughts around having a webpack plugin that could handle resolving across the entire project, but it would lead to duplicate fragments (and in general felt like a lot of work). the newest version of |
@jnwng if the loader does batch processing, then there is no need for any inclusion tags. On the first pass, it loads all files and caches all fragments & actions. Then it loops through the actions and populates the fragments. In the case of duplicates, a flag can be set to let the last win or raise an error. This is done at the start of your app, and only once. |
Same issue here. I was able to add the
module.exports = {
module: {
rules: [
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
],
},
}; |
Guys, I'm having a problem using this loader as well, I'm trying to pre-process the queries using webpack, but, seems that the fragment import is not working, gonna share my problem if anyone has any idea of what is going on: My fragment file
|
The fragments are not pulled into the query document using the loader.
Example:
The
apollo-codegen
handles the above scenario well when generating the schema.ts file.However,
graphql-tag/loader
is unable to insert the fragments in this example.One thing to notice is that
graphql-tag/loader
works well when the fragments are also located in the same file as the query that is referencing them.The fragments should be pulled in via the loader, however, that is not the case as per this issue.
So, we need the fragments to be in separate files and
apollo-codegen
handles them properly when compiling the schema.ts. We just have to ensure that theloader
in this module is also properly including them in each query.=====
Version:
"graphql-tag": "^1.2.4",
node: 6.9.5
os: darwin x64
The text was updated successfully, but these errors were encountered: