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

When including a document node with sub fragments in gql tag include all fragments #125

Open
k opened this issue Sep 28, 2017 · 8 comments

Comments

@k
Copy link

k commented Sep 28, 2017

Say I have a fragment A which has two fragments B and C

fragmentA.gql:

#import "fragmentB"
#import "fragmentC"

fragment A {
  ...B
  items {
      ...C
   }
}

which I import like so:

import fragmentA from './fragmentA.gql'

if I use fragment A in query D like so:

export const queryD = gql`
query getSomeAlphabet {
      id
      ...A
}
${fragmentA}`

The document node queryD only has 2 definitions, the getSomeAlphabet query and A but not the definitions for B and C.

Is this a bug, or am I doing something wrong here?

@jnwng
Copy link
Contributor

jnwng commented Sep 28, 2017 via email

@k
Copy link
Author

k commented Sep 28, 2017

Thanks @jnwng for the quick response. I forgot to include in the original fragment, but there are two #import statements pulling in the other fragments that are used. Is that what you were referring to?

@jnwng
Copy link
Contributor

jnwng commented Sep 28, 2017 via email

@k
Copy link
Author

k commented Sep 28, 2017

I logged the equivalent of fragmentA and i double checked it had all the definitions, but when putting it into queryD it only had to the top level fragment from fragmentA unfortunately.

@k
Copy link
Author

k commented Sep 28, 2017

The way I got around this was to make a separate .gql file for queryD and #import fragmentA

@jnwng
Copy link
Contributor

jnwng commented Sep 28, 2017 via email

@k
Copy link
Author

k commented Sep 28, 2017

@jnwng Is that being tracked elsewhere? Sometimes its more convenient to use the gql tag because its the only way I know of to allow multiple import/exports (until #102 is completed)

@k k changed the title When adding a document node with sub fragments include all fragments When including a document node with sub fragments in gql tag include all fragments Sep 28, 2017
@jnwng
Copy link
Contributor

jnwng commented May 28, 2018

i believe this is resolved by #105 and has to do with how we serialize stuff using the webpack loader.

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

No branches or pull requests

2 participants