Fragment spreads are not included within the main query #5385
Unanswered
EmmanuelPonnudurai
asked this question in
General
Replies: 1 comment
-
GraphQL Tag Pluck doesn't parse documents. It extracts the GraphQL strings one by one. That's why, two different appearance of gql tag are returned as two different sources. This is the expected behavior. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there. Thanks for the wonderful toolset that you've created.
I am trying to generate the definitions for the queries in my application. While doing this, I notice that the results have fragments and queries separately. This makes it hard for me to tie them up together.
Consider this situation,
file1.ts
file2.ts
Here is how I generate the definitions,
I get two items in the
Source[]
array. One for the query and another for the fragment.In the first item, rawSDL is,
In the second item, rawSDL is,
My question is, why is the fragment spread definition not included within the first item as well? My expectation is to see something like this,
The reason this is important for my use case is because I need to definitively know the entire query string contents, as I must save them on the backend in advance (as part of a build step).
If I get them separately. How will I be able to know that the spread fragment with the term
moreData
is to be pulled from the second item. There could be another fragment definition in another file which has the same namemoreData
but it asks for more or less # of fields. So, I will not know which one to pick and associate properly, even if I was to manually tie them up together.Is there some pointer or reference on the main query
Source
result which says this fragment spread is to be taken from this file or some way to precisely tie them up.I tried using the graphql tag pluck option and that also doesn't yields same results. Followed the sample from here https://the-guild.dev/graphql/tools/docs/graphql-tag-pluck
Pls let me know if im taking the right direction or if there is something I'm missing.
Thanks in advance for your guidance and pointers to help me resolve this.
Beta Was this translation helpful? Give feedback.
All reactions