Hi,
I wanted to nest a fragment in another fragment.
Just like this. https://learngraphql.com/basics/fragments/4
Is this possible with this package? It seems it is not working with my project which is on top of one of the starters I'm using, which depends on this package.
Or maybe a upcoming feature?
I tried to search all the issues here and couldn't find a similar discussion.
Oh I'm using v2.0.0
yes - you can nest fragments within fragments using graphql-tag. you'll want to make sure you import both the fragments though:
const fragment = gql`
fragment Foo on Something {
someField
}
`;
const anotherFragment = gql`
fragment Bar on Something {
anotherField
...Foo
}
${fragment}
`;
is valid. note that we're interpolating the first fragment in the second one.
you'll also want to make sure that the nested fragment types are the same! notice in the example that both fragments are on Something
Most helpful comment
yes - you can nest fragments within fragments using
graphql-tag. you'll want to make sure you import both the fragments though:is valid. note that we're interpolating the first fragment in the second one.