Skip to content

Field name argument doesn't work with interface types #566

Closed
@twavv

Description

@twavv

Describe the bug

@InterfaceType
abstract class Animal {
  @Field(() => String, { name: "animalName" })
  abstract getAnimalName: () => Promise<string>;
}

@ObjectType({ implements: [Animal] })
export class Dog {
  async getAnimalName() { return "Fido"; }
  /* ... */
}

The generated schema is along the lines of

interface Animal {
  animalName: String!
}

but if you try to query, you get a GraphQL error along the lines of

Error: Cannot return null for non-nullable field Dog.animalName

seemingly because the mapping from animalName to getAnimalName hasn't happened.

Addendum:
I see that name isn't supported in some other places (#263) but this doesn't seem like the same situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions