Skip to content

Why are @key annotations enfored for types implementing interface? #1291

@klys-equinix

Description

@klys-equinix

I have an interface with an entity resolver like

interface Asset @key(fields: "id") {
    id: ID! # read only
    ...
}

And several types implementing it. Some of them are referenced from external schemas, and so they get their own @EntityMapping,
but most are not.
If I do not add a @key annotation, i will get

Caused by: com.apollographql.federation.graphqljava.exceptions.MissingKeyException: Object Ups does not specify @key fields specified by its interface Asset

for

type Ups implements Asset & ElecAsset {
    id: ID!

Why is it enforced like that?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions