Skip to content

Multiple interpolation of same fragment #4

@eknkc

Description

@eknkc

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions