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

Fragment importing another fragment does not work in interpolation #159

Open
intellisense opened this issue Feb 26, 2018 · 3 comments · May be fixed by #283
Open

Fragment importing another fragment does not work in interpolation #159

intellisense opened this issue Feb 26, 2018 · 3 comments · May be fixed by #283

Comments

@intellisense
Copy link

intellisense commented Feb 26, 2018

Hi, Consider this:

FieldBaseFragment.gql

fragment FieldBaseFragment on Field {
  id
}

FieldDetailFragment.gql

#import "./FieldBaseFragment.gql"

fragment FieldDetailFragment on Field {
  ...FieldBaseFragment
  name
}

mutations.js

import gql from 'graphql-tag'

import FieldDetailFragment from './FieldDetailFragment.gql'

const CreateFieldMutation = gql`
  mutation CreateFieldMutation($field: FieldInput!) {
    storeField(input: $field) {
      field {
        ...FieldDetailFragment
      }
  }
  ${FieldDetailFragment}
`

Invoking CreateFieldMutation chokes and throws error that Error: GraphQL error: Unknown fragment "FieldBaseFragment"

Using: graphql-tag==2.4.2 also tested on latest version same error.

@intellisense
Copy link
Author

I think this is related to #105

@j0nd0n7
Copy link

j0nd0n7 commented Nov 13, 2018

I'm using the new Create React App 2.X which now has official support for loading .graphql files.
While migration I have a issue if a fragment #imports a fragment. The first reference works (Query #import Fragment) but the second level and higher (Query #import Fragment #import Fragment ...) doesn't work.

(I'm not sure if CRA uses this package to load .graphql files)

@bmulholland
Copy link

In the intervening years, the proposed solutions have evolved a bit. To save future people from following the rabbit hole as I did, the most up-to-date PR is at #227. However, that hasn't been touched in over 2 years, so I seriously doubt this will be fixed anytime soon. From what I can see, there simply isn't anyone at Apollo who is lending this work the necessary sponsorship or reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants