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

Multiple interpolation of same fragment #4

Closed
eknkc opened this issue Sep 23, 2018 · 2 comments
Closed

Multiple interpolation of same fragment #4

eknkc opened this issue Sep 23, 2018 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@eknkc
Copy link

eknkc commented Sep 23, 2018

Hi,

While trying to switch to the transformer I've ran into an issue; say:

const a = gql`
  fragment a on A {
    id
  }
`

const b = gql`
  fragment b on B {
    id
    child {
      ...a 
    } 
  } 
  ${a}
`

const c = gql`
  fragment c on C {
    id
    childA { ...a }
    childB { ...b }
  }
  ${a}
  ${b}
`

Now the c fragment basically embeds a twice. Once itself, once via b. graphql-tag handles this on runtime and does not embed the duplicate. However the compile time transformation follows a twice. Causing a query error.

I'm not familiar with the ts visitor api but I guess it could be possible to find duplicate references in a single interpolation tree and skip duplicates. Is it possible or does it require some runtime knowledge?

Thanks!

@firede firede added the help wanted Extra attention is needed label Sep 29, 2018
@firede
Copy link
Owner

firede commented Sep 29, 2018

This requires the context of interpolation.
Regrettably, I have no free time to do this improvement recently :(
I marked the issue as help wanted and kept it open.

@eltonio450
Copy link

seems related to apollographql/graphql-tag#278

@eknkc eknkc closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants