Skip to content

Commit 4299d8c

Browse files
committed
Simplify examples
1 parent c0b82d5 commit 4299d8c

File tree

1 file changed

+44
-91
lines changed

1 file changed

+44
-91
lines changed

spec/Section 3 -- Type System.md

Lines changed: 44 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,25 +2070,35 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
20702070

20712071
## Schema Coordinates
20722072

2073-
Schema Coordinates are human readable strings that uniquely identify a specific
2074-
type, field, argument, enum value, or directive defined in a GraphQL Schema.
2075-
20762073
SchemaCoordinate :
20772074
- Name
20782075
- Name . Name
20792076
- Name . Name ( Name : )
20802077
- @ Name
20812078
- @ Name ( Name : )
20822079

2083-
Note: A {SchemaCoordinate} is not a definition within a GraphQL {Document}.
2084-
Schema coordinates are a separate syntax, intended to be used by tools to
2085-
reference types and fields or other schema elements. For example: within
2086-
documentation, or as lookup keys a service uses to track usage frequency.
2080+
:: A *schema coordinate* is a human readable string that uniquely identifies a
2081+
*schema element* within a GraphQL Schema.
2082+
2083+
:: A *schema element* is a specific instance of a named type, type field,
2084+
input field, enum value, field argument, directive, or directive argument.
2085+
2086+
A *schema coordinate* is always unique. Each *schema element* may be referenced
2087+
by exactly one possible schema coordinate.
2088+
2089+
A *schema coordinate* may refer to either a defined or built-in *schema element*.
2090+
For example, `String` and `@deprecated(reason:)` are both valid schema
2091+
coordinates which refer to built-in schema elements.
2092+
2093+
Note: A {SchemaCoordinate} is not a definition within a GraphQL {Document}, but
2094+
a separate stand-alone grammar, intended to be used by tools to reference types,
2095+
fields, and other *schema element*s. For example as references within
2096+
documentation, or as lookup keys in usage frequency tracking.
20872097

20882098
**Semantics**
20892099

2090-
A schema coordinate's semantics assume they are interpreted in the context of
2091-
a single GraphQL {schema}.
2100+
To refer to a *schema element*, a *schema coordinate* must be interpreted in the
2101+
context of a GraphQL {schema}.
20922102

20932103
SchemaCoordinate : Name
20942104
1. Let {typeName} be the value of the first {Name}.
@@ -2131,97 +2141,40 @@ SchemaCoordinate : @ Name ( Name : )
21312141

21322142
**Examples**
21332143

2134-
This section shows example coordinates for the possible schema element types
2135-
this syntax covers.
2136-
2137-
All examples below will assume the following schema:
2138-
2139-
```graphql example
2140-
directive @private(scope: String!) on FIELD
2141-
2142-
scalar DateTime
2143-
2144-
input ReviewInput {
2145-
content: String
2146-
author: String
2147-
businessId: String
2148-
}
2149-
2150-
interface Address {
2151-
city: String
2152-
}
2144+
| Element Kind | *Schema Coordinate* | *Schema Element* |
2145+
| ------------------ | -------------------------------- | ----------------------------------------------------------------------- |
2146+
| Named Type | `Business` | `Business` type |
2147+
| Type Field | `Business.name` | `name` field on the `Business` type |
2148+
| Input Field | `SearchCriteria.filter` | `filter` input field on the `SearchCriteria` input object type |
2149+
| Enum Value | `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
2150+
| Field Argument | `Query.searchBusiness(criteria:)`| `criteria` argument on the `searchBusiness` field on the `Query` type |
2151+
| Directive | `@private` | `@private` directive |
2152+
| Directive Argument | `@private(scope:)` | `scope` argument on the `@private` directive |
21532153

2154-
type User implements Address {
2155-
name: String
2156-
reviewCount: Int
2157-
friends: [User]
2158-
email: String @private(scope: "loggedIn")
2159-
city: String
2160-
}
2154+
The table above shows an example of a *schema coordinate* for every kind of
2155+
*schema element* based on the schema below.
21612156

2162-
type Business implements Address {
2163-
name: String
2164-
address: String
2165-
rating: Int
2166-
city: String
2167-
reviews: [Review]
2168-
createdAt: DateTime
2157+
```graphql
2158+
type Query {
2159+
searchBusiness(criteria: SearchCriteria!): [Business]
21692160
}
21702161

2171-
type Review {
2172-
content: String
2173-
author: User
2174-
business: Business
2175-
createdAt: DateTime
2162+
input SearchCriteria {
2163+
name: String
2164+
filter: SearchFilter
21762165
}
21772166

2178-
union Entity = User | Business | Review
2179-
21802167
enum SearchFilter {
2181-
OPEN_NOW
2182-
DELIVERS_TAKEOUT
2183-
VEGETARIAN_MENU
2184-
}
2185-
2186-
type Query {
2187-
searchBusiness(name: String!, filter: SearchFilter): Business
2168+
OPEN_NOW
2169+
DELIVERS_TAKEOUT
2170+
VEGETARIAN_MENU
21882171
}
21892172

2190-
type Mutation {
2191-
addReview(input: ReviewInput!): Review
2173+
type Business {
2174+
id: ID
2175+
name: String
2176+
email: String @private(scope: "loggedIn")
21922177
}
2193-
```
21942178

2195-
The following table shows examples of Schema Coordinates for elements in the
2196-
schema above:
2197-
2198-
| Schema Coordinate | Description |
2199-
| ------------------------------ | ------------------------------------------------------------------- |
2200-
| `Business` | `Business` type |
2201-
| `User.name` | `name` field on the `User` type |
2202-
| `Query.searchBusiness(name:)` | `name` argument on the `searchBusiness` field on the `Query` type |
2203-
| `SearchFilter` | `SearchFilter` enum |
2204-
| `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the`SearchFilter` enum |
2205-
| `@private` | `@private` directive definition |
2206-
| `@private(scope:)` | `scope` argument on the `@private` directive definition |
2207-
| `Address` | `Address` interface |
2208-
| `Address.city` | `city` field on the `Address` interface |
2209-
| `ReviewInput` | `ReviewInput` input object type |
2210-
| `ReviewInput.author` | `author` input field on the `ReviewInput` input object type |
2211-
| `Entity` | `Entity` union definition |
2212-
| `DateTime` | Custom `DateTime` scalar type |
2213-
| `String` | Built-in `String` scalar type |
2214-
2215-
Schema Coordinates are always unique. Each type, field, argument, enum value, or
2216-
directive may be referenced by exactly one possible Schema Coordinate.
2217-
2218-
For example, the following is *not* a valid Schema Coordinate:
2219-
2220-
```graphql counter-example
2221-
Entity.Business
2179+
directive @private(scope: String!) on FIELD
22222180
```
2223-
2224-
In this counter example, `Entity.Business` is redundant since `Business` already
2225-
uniquely identifies the Business type. Such redundancy is disallowed by this
2226-
spec - every type, field, field argument, enum value, directive, and directive
2227-
argument has exactly one canonical Schema Coordinate.

0 commit comments

Comments
 (0)