Skip to content

Commit 1f975e4

Browse files
committed
Rework capabilities
1 parent 0fa7a33 commit 1f975e4

File tree

1 file changed

+84
-128
lines changed

1 file changed

+84
-128
lines changed

spec/Section 4 -- Introspection.md

Lines changed: 84 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ are the full set of type system definitions providing schema introspection,
125125
which are fully defined in the sections below.
126126

127127
```graphql
128-
type __Service {
129-
capabilities: [String!]!
130-
defaultErrorBehavior: __ErrorBehavior!
131-
}
132-
133128
type __Schema {
134129
description: String
135130
types: [__Type!]!
@@ -170,12 +165,6 @@ enum __TypeKind {
170165
NON_NULL
171166
}
172167

173-
enum __ErrorBehavior {
174-
NO_PROPAGATE
175-
PROPAGATE
176-
HALT
177-
}
178-
179168
type __Field {
180169
name: String!
181170
description: String
@@ -230,125 +219,16 @@ enum __DirectiveLocation {
230219
INPUT_OBJECT
231220
INPUT_FIELD_DEFINITION
232221
}
233-
```
234-
235-
### The \_\_Service Type
236-
237-
The `__Service` type is returned from the `__service` meta-field and provides
238-
information about the GraphQL service, most notably about its capabilities. This
239-
type was added after the original release of GraphQL, so older schemas may not
240-
support it.
241-
242-
Fields\:
243-
244-
- `capabilities` must return a list of strings indicating the capabilities
245-
supported by the service.
246-
- `defaultErrorBehavior` must return the _default error behavior_ of the service
247-
using one of the values of the `__ErrorBehavior` enum:
248-
- {"NO_PROPAGATE"}
249-
- {"PROPAGATE"}
250-
- {"HALT"}
251-
252-
**Capabilities**
253-
254-
As GraphQL becomes more feature rich, clients need to understand the features
255-
that a service supports so that they only send compatible requests; the
256-
`__Service.capabilities` field reveals these capabilities.
257-
258-
Note: Prior to the introduction of the capabilities system, a client would
259-
either require out-of-band communication to discover the capabilities of a
260-
schema, or would need to perform multiple introspection phases determining the
261-
fields available in introspection in order to perform feature discovery.
262-
263-
Capabilities may be supplied by the GraphQL implementation, by the service, or
264-
both.
265-
266-
A individual capability is described by a string, {CapabilityString}, inspired
267-
by reverse domain name notation to ensure globally unique and
268-
collision-resistant identifiers. A capability string must be composed of two or
269-
more {CompatibilitySegment}, separated by a period (`.`). A {CapabilitySegment}
270-
is a non-empty string composed only from ASCII letter (`[a-zA-Z]`), digits
271-
(`[0-9]`), or hyphens (`-`); it must start with an ASCII letter and must not
272-
terminate with a hyphen.
273-
274-
CapabilityString ::
275-
276-
- CapabilityString . CapabilitySegment
277-
- CapabilitySegment . CapabilitySegment
278-
279-
CapabilitySegment ::
280-
281-
- CapabilitySegmentStart
282-
- CapabilitySegmentStart CapabilitySegmentContinue\* CapabilitySegmentEnd
283-
284-
CapabilitySegmentStart :: Letter
285-
286-
CapabilitySegmentContinue ::
287-
288-
- Letter
289-
- Digit
290-
- `-`
291-
292-
CapabilitySegmentEnd ::
293-
294-
- Letter
295-
- Digit
296-
297-
Identifiers beginning with the prefix {"org.graphql."} are reserved and must not
298-
be used outside of official GraphQL Foundation specifications. Further,
299-
identifiers beginning with the prefix {"org.graphql.http."} are reserved for use
300-
by the GraphQL-over-HTTP specification, and identifiers beginning with the
301-
prefix {"org.graphql.rfc."} are reserved for RFC proposals.
302-
303-
Identifiers defined by specific projects, vendors, or implementations should
304-
begin with a prefix derived from a DNS name they control (e.g.,
305-
{"com.example."})
306-
307-
Clients should use string equality to check for known identifiers, and should
308-
ignore unknown identifiers.
309-
310-
Implementers should not change the meaning of capability identifiers, instead a
311-
new capability identifier should be used when the meaning changes. Implementers
312-
should ensure that capability strings remain stable and version-agnostic where
313-
possible; capability versioning, if needed, can be indicated using dot suffixes
314-
(e.g.{ "org.example.capability.v2"}).
315222

316-
This system enables incremental feature adoption and richer tooling
317-
interoperability, while avoiding tight coupling to specific implementations.
223+
type __Service {
224+
capabilities: [__Capability!]!
225+
}
318226

319-
Implementers of earlier versions of this specification may choose to implement
320-
the capabilities system, but when doing so they must not include capabilities
321-
that they do not support.
322-
323-
Implementers of this version of this specification must include the following
324-
capabilities:
325-
326-
- {"org.graphql.scalar.specifiedBy"} - indicates the ability to request the
327-
_scalar specification URL_ of a scalar via the `__Type.specifiedBy`
328-
introspection field
329-
- {"org.graphql.directive.repeatable"} - indicates support for repeatable
330-
directive and the related `__Directive.isRepeatable` introspection field
331-
- {"org.graphql.schema.description"} - indicates the ability to request a
332-
description of the schema via the `__Schema.description` introspection field
333-
- {"org.graphql.deprecation.inputValues"} - indicates support for deprecating
334-
input values along with the related introspection schema coordinates:
335-
- `__Directive.args(includeDeprecated:)`,
336-
- `__Field.args(includeDeprecated:)`,
337-
- `__Type.inputFields(includeDeprecated:)`,
338-
- `__InputValue.isDeprecated`, and
339-
- `__InputValue.deprecationReason`.
340-
- {"org.graphql.inputObject.oneOf"} - indicates support for OneOf Input Objects
341-
and the related introspection field `__Type.isOneOf`
342-
- {"org.graphql.errorBehavior"} - indicates that the
343-
`__Service.defaultErrorBehavior` field exists, which indicates the the
344-
_default error behavior_ of the service
345-
346-
If the schema, implementation, and service support the subscription operation,
347-
the {"org.graphql.subscription"} capability should be included.
348-
349-
If the service accepts the {onError} request parameter, the
350-
{"org.graphql.onError"} capability should be included. If it is not included,
351-
clients should infer the default will be used for all requests.
227+
type __Capability {
228+
identifier: String!
229+
value: String
230+
}
231+
```
352232

353233
### The \_\_Schema Type
354234

@@ -630,3 +510,79 @@ Fields\:
630510
{true}, deprecated arguments are also returned.
631511
- `isRepeatable` must return a Boolean that indicates if the directive may be
632512
used repeatedly at a single location.
513+
514+
### The \_\_Service Type
515+
516+
The `__Service` type is returned from the `__service` meta-field and provides
517+
information about the GraphQL service, most notably about its capabilities. This
518+
type was added after the original release of GraphQL, so older schemas may not
519+
support it.
520+
521+
Fields\:
522+
523+
- `capabilities` must return a list of `__Capability` indicating the
524+
capabilities supported by the service.
525+
526+
### The \_\_Capability Type
527+
528+
The `__Service.capabilities` field exposes a list of capabilities that describe
529+
features supported by the GraphQL service but not directly expressible in the
530+
type system. These may include experimental GraphQL features (such as fragment
531+
arguments, operation descriptions, custom error behaviors), protocol support
532+
(such as subscriptions over WebSocket), or additional operational metadata (such
533+
as release identifiers).
534+
535+
Capabilities may be supplied by the GraphQL implementation, by the service, or
536+
both. An individual entry in the capabilities list will have a capability
537+
identifier and may optionally provide a string value.
538+
539+
**Capability identifier**
540+
541+
Capability identifiers are inspired by reverse domain name notation in order to
542+
help them be globally unique and collision-resistant. They are a string value
543+
composed of two or more segments separated by a period (`.`). Each segment must
544+
begin with a letter and must contain only alphanumeric characters and hyphens
545+
(`[a-zA-Z][a-zA-Z0-9-]*`). Unlike the domain name system, capability identifiers
546+
are case sensitive. Identifiers beginning with the prefix {"org.graphql."} are
547+
reserved and must not be used outside of official GraphQL Foundation
548+
specifications. Further, identifiers beginning with the prefix
549+
{"org.graphql.http."} are reserved for use by the GraphQL-over-HTTP
550+
specification, and identifiers beginning with the prefix {"org.graphql.rfc."}
551+
are reserved for RFC proposals.
552+
553+
Identifiers defined by specific projects, vendors, or implementations should
554+
begin with a prefix derived from a DNS name they control (e.g.,
555+
{"com.example."}).
556+
557+
Clients should use string equality to check for known identifiers, and should
558+
ignore unknown identifiers.
559+
560+
Implementers should not change the meaning of capability identifiers, instead a
561+
new capability identifier should be used when the meaning changes. Implementers
562+
should ensure that capability strings remain stable and version-agnostic where
563+
possible; capability versioning, if needed, can be indicated using dot suffixes
564+
(e.g.{ "org.example.capability.v2"}).
565+
566+
This system enables incremental feature adoption and richer tooling
567+
interoperability, while avoiding tight coupling to specific implementations.
568+
569+
**Capability value**
570+
571+
The value assigned to a given capability may either be {null} to indicate that
572+
the capability is supported and requires no additional information, or a string
573+
to provide additional information. For example
574+
{"org.graphql.rfc.fragmentArguments"} does not require additional information
575+
and thus would have value {null}, whereas {"org.graphql.websockets"} might
576+
indicate support for websockets whilst using the value to indicate the endpoint
577+
to use.
578+
579+
**Specified capabilities**
580+
581+
This version of the specification defines the following capabilities:
582+
583+
- {"org.graphql.defaultErrorBehavior"} - indicates the _default error behavior_
584+
of the service via the {value}. If not present, must be assumed to be
585+
{"PROPAGATE"}.
586+
- {"org.graphql.onError"} - indicates that the service allows the client to
587+
specify {onError} in a request to indicate the _error behavior_ the service
588+
should use for the request. {value} is {null}.

0 commit comments

Comments
 (0)