msolomon / argo

Argo is a compact and compressible binary serialization format for GraphQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect type for fields in fragment

jbourassa opened this issue · comments

The reference implementation can mistype fields in fragments.

Given this schema:

type Query {
  hero: Character
}

interface Character { id: ID! }

type Droid implements Character {
  id: ID!
  name: Int!
}

type Human implements Character {
  id: ID!
  name: String!
}

and this query:

query {
  hero {
    ... on Human { name }
  }
}

Name will be defied as name?: VARINT{Int} on the wire type, but Human.name is a String!. I would expect the wire type to be name?: STRING<String>. I put together a failing test with this exact example.

If you agree this is a bug, I can try my hand at a fix. My [not yet published] Ruby implementation uses the fragment's type condition to use the right type to lookup the field, instead of using all possible types. That seems to work, so far.

It turns out the Erlang implementation also suffers from this problem, here's the fix that works similar to what @jbourassa said is being done in the Ruby version: WhatsApp/erlang-argo@bfa5b4b

Thanks for looking into this, it's definitely a bug! I'll get it fixed in a new version.

It's fixed in the latest reference implementation, 1.1.1. Thanks again!