Skip to content

failure to require leaf field selection when using fragments #610

@VladimirAlexiev

Description

@VladimirAlexiev

Assume a simple schema like this:

interface Character {name:String!}
type Human implements Character {name:String!}
type Droid implements Character {name:String!}
type Query {
  characters: [Character!]
}

This query is not valid because it does not select down to leaf (scalar) fields (see https://graphql.github.io/graphql-spec/draft/#sec-Leaf-Field-Selections):

{characters {
}}

Then why is this query valid? It selects a scalar field, but only for Human. It'd return Droids without any fields i.e. {}.

{characters {
   ... on Human {name}
}}

I asked the question on:

andrewingram replied: it's valid, which can seem counter-intuitive. it's valid in graphql-js, which is aligned with the spec.

I think the query exposes an omission in the spec?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions