Skip to content
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

Question: Empty fragments don't seem to work #332

Open
clemmy opened this issue Jan 9, 2021 · 1 comment
Open

Question: Empty fragments don't seem to work #332

clemmy opened this issue Jan 9, 2021 · 1 comment

Comments

@clemmy
Copy link

clemmy commented Jan 9, 2021

I have a .gql file that doesn't include any fragments or queries, but instead has a list of imports.

For example,

a.gql:

#import 'third-party/b.gql'
#import 'third-party/c.gql'
#import 'third-party/d.gql'

The use case is for when I want to include a group of common fragments into multiple files, but want to keep that group managed in a central file so I don't need to repeat myself. Is this a use case that is supported?

@ETRick
Copy link

ETRick commented Jan 26, 2021

I think that is supported. It seems that graphql-tag/loader.js will import these #import xxxx.gql when building.

here's what loader do:

graphql-tag/loader.js

Lines 29 to 37 in 292bb8f

lines.some((line) => {
if (line[0] === '#' && line.slice(1).split(' ')[0] === 'import') {
const importFile = line.slice(1).split(' ')[1];
const parseDocument = `require(${importFile})`;
const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument}.definitions));`;
outputCode += appendDef + os.EOL;
}
return (line.length !== 0 && line[0] !== '#');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants