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

Fix/concat document definitions #1

Closed
wants to merge 3 commits into from

Conversation

nhodges
Copy link
Owner

@nhodges nhodges commented Jan 22, 2020

Issue Fixed apollographql#159

Proposed Changes

  • Concatenate document definitions while filtering for duplicates

@daniellmb

Based on PR apollographql#105 by @evanrs, updated for current version of graphql-tag

Document fragments parsed by graphql-tag/loader lose their definitions when used with a gql tagged template literal. This is fixed by concatenating the document definitions—filtering for duplicates.

Without this, the following would fail:

import catFaceFragment from './catFaceFragment.gql';

const query = gql`
  query Kitten($name: String) {
    kitten(name: $name) {
      ... CatFace
    }
  }
  ${catFaceFragment}
`
#import "./whiskers.gql"

fragment CatFace on Cat {
  ... Whiskers
}
fragment Whiskers on Cat {
  whiskers {
    quantity
    length
    areWiderThanBody
  }  
}
Unknown fragment "Whiskers".

@nhodges nhodges closed this Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fragment importing another fragment does not work in interpolation
1 participant