2

I use ApolloClient 3 and webpack's graphql-tag/loader. The beginning of my file looks like:

#import '../../hooks/fragments/User/basicUserInfo.gql'

fragment IsLeftSidebarOpen on Query {
  isLeftSidebarOpen @client
}

These 3 following snippets are in the same file that IsLeftSidebarOpen fragment is. Of course I test them one by one by changing file, not all at once. Could you explain me why

a) this works

query FetchData {
  me {
    ...BasicUserInfo
  }
  isLeftSidebarOpen @client
}

b) this also works

query FetchData {
  ...IsLeftSidebarOpen @client
}

c) but this throws the following error Unknown fragment "IsLeftSidebarOpen"

query FetchData {
  me {
    ...BasicUserInfo
  }
  ...IsLeftSidebarOpen @client
}

3
  • It's not clear from your question where IsLeftSidebarOpen is defined and how you are importing it. Also, if you're using the graphql-tag loader, that should be mentioned. Commented Nov 19, 2019 at 14:03
  • @DanielRearden sorry, I've just edited my question Commented Nov 19, 2019 at 14:28
  • @TomaszSuperson Did you solve the issue? I’m running into the same problem...
    – debite
    Commented Mar 19, 2020 at 8:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.