typelevel / grackle

Grackle: Functional GraphQL for the Typelevel stack
http://typelevel.org/grackle/
Apache License 2.0
176 stars 25 forks source link

`__typename` in `fragment` #520

Closed swalker2m closed 10 months ago

swalker2m commented 10 months ago

A co-worker uses a tool (SGQLC) to generate queries. It seems to like inserting __typename wherever it can. One such place is in fragments. Unfortunately this may (?) not be working with Grackle. For example this query is fine:

query {
  human(id: 1002) {
    friends {
      __typename
      ...CharacterFields
    }  
  }
}
fragment CharacterFields on Character {
  id
}

but this similar query fails with No field '__typename' for type Character:

query {
  human(id: 1002) {
    friends {
      ...CharacterFields
    }  
  }
}
fragment CharacterFields on Character {
  __typename
  id
}
swalker2m commented 10 months ago

This inline fragment with __typename also works:

query {
  human(id: 1002) {
    friends {
      ... on Character {
        __typename
        id
      }
    }  
  }
}