graphQLKeyDirective top-level property

GraphQLDirective graphQLKeyDirective
final

Specifies that a given Object can be identified by the fields passed as argument to the directive

It is repeatable, there can be multiple keys per Object.

The following example shows an Object that can be identified by two keys, the "id" field and the combination "type" and "nested.value" fields.

type Model @key(fields: "id") @key(fields: "type nested { value } ") {
  id: String!
  type: String!
  nested {
    value: int!
  }
}

Implementation

final graphQLKeyDirective = GraphQLDirective(
  name: 'key',
  description: 'Specifies that a given object can be identified by the fields'
      ' passed as argument to the directive.',
  locations: [DirectiveLocation.OBJECT],
  isRepeatable: true,
  inputs: [
    GraphQLFieldInput<String, String>(
      'fields',
      graphQLString.nonNull(),
      description: 'The fields which, when combined, form a'
          ' global key for the annotated GraphQLObject.',
    ),
  ],
);