Closed jefersoneiji closed 11 months ago
Hello! Thank you Nexus team for creating this library that's realy helpful for working with GraphQL.
I'm using typescript, apollo server and nexus graphql.
By following the GraphQL specs on interfaces an issue on the type level occurs.
But if i change from data.brand to one of fields from Character Interface only character fields are returned.
data.brand
Character Interface
And this query stops working by no longer returning the brand field only name field.
brand
name
query HeroForEpisode($ep: Episode!) { hero(episode: $ep) { name ... on Droid { brand } } }
const Character = interfaceType({ name: 'Character', definition(t) { t.nonNull.id('id'); t.nonNull.string('name'); t.nonNull.int('age'); }, });
const Human = objectType({ name: 'Human', description: 'Human type of character', definition(t) { t.implements('Character'); t.nonNull.id('id'); t.nonNull.string('name'); t.nonNull.int('age'); t.nonNull.string('country'); }, isTypeOf(data) { return Boolean(data.country); } });
const Droid = objectType({ name: 'Droid', description: 'Droid type of character', definition(t) { t.implements('Character'); t.nonNull.id('id'); t.nonNull.string('name'); t.nonNull.int('age'); t.nonNull.string('brand'); }, isTypeOf(data) { return Boolean(data.brand); } });
const Hero = extendType({ type: 'Query', definition(t) { t.field('hero', { type: 'Character', args: { id: idArg() }, description: 'Query for characters', resolve(parent, args, context) { return expectedResult; } }); }, });
Hello! Thank you Nexus team for creating this library that's realy helpful for working with GraphQL.
I'm using typescript, apollo server and nexus graphql.
By following the GraphQL specs on interfaces an issue on the type level occurs.
But if i change from
data.brand
to one of fields fromCharacter Interface
only character fields are returned.And this query stops working by no longer returning the
brand
field onlyname
field.The Interface
Human Object Type
Droid Object Type
Hero Query