Skip to content

Commit 8580162

Browse files
leebyronmagicmark
authored andcommitted
Simplify examples
1 parent b8f3f47 commit 8580162

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
@@ -2168,25 +2168,35 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
21682168

21692169
## Schema Coordinates
21702170

2171-
Schema Coordinates are human readable strings that uniquely identify a specific
2172-
type, field, argument, enum value, or directive defined in a GraphQL Schema.
2173-
21742171
SchemaCoordinate :
21752172
- Name
21762173
- Name . Name
21772174
- Name . Name ( Name : )
21782175
- @ Name
21792176
- @ Name ( Name : )
21802177

2181-
Note: A {SchemaCoordinate} is not a definition within a GraphQL {Document}.
2182-
Schema coordinates are a separate syntax, intended to be used by tools to
2183-
reference types and fields or other schema elements. For example: within
2184-
documentation, or as lookup keys a service uses to track usage frequency.
2178+
:: A *schema coordinate* is a human readable string that uniquely identifies a
2179+
*schema element* within a GraphQL Schema.
2180+
2181+
:: A *schema element* is a specific instance of a named type, type field,
2182+
input field, enum value, field argument, directive, or directive argument.
2183+
2184+
A *schema coordinate* is always unique. Each *schema element* may be referenced
2185+
by exactly one possible schema coordinate.
2186+
2187+
A *schema coordinate* may refer to either a defined or built-in *schema element*.
2188+
For example, `String` and `@deprecated(reason:)` are both valid schema
2189+
coordinates which refer to built-in schema elements.
2190+
2191+
Note: A {SchemaCoordinate} is not a definition within a GraphQL {Document}, but
2192+
a separate stand-alone grammar, intended to be used by tools to reference types,
2193+
fields, and other *schema element*s. For example as references within
2194+
documentation, or as lookup keys in usage frequency tracking.
21852195

21862196
**Semantics**
21872197

2188-
A schema coordinate's semantics assume they are interpreted in the context of
2189-
a single GraphQL {schema}.
2198+
To refer to a *schema element*, a *schema coordinate* must be interpreted in the
2199+
context of a GraphQL {schema}.
21902200

21912201
SchemaCoordinate : Name
21922202
1. Let {typeName} be the value of the first {Name}.
@@ -2229,97 +2239,40 @@ SchemaCoordinate : @ Name ( Name : )
22292239

22302240
**Examples**
22312241

2232-
This section shows example coordinates for the possible schema element types
2233-
this syntax covers.
2242+
| Element Kind | *Schema Coordinate* | *Schema Element* |
2243+
| ------------------ | -------------------------------- | ----------------------------------------------------------------------- |
2244+
| Named Type | `Business` | `Business` type |
2245+
| Type Field | `Business.name` | `name` field on the `Business` type |
2246+
| Input Field | `SearchCriteria.filter` | `filter` input field on the `SearchCriteria` input object type |
2247+
| Enum Value | `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
2248+
| Field Argument | `Query.searchBusiness(criteria:)`| `criteria` argument on the `searchBusiness` field on the `Query` type |
2249+
| Directive | `@private` | `@private` directive |
2250+
| Directive Argument | `@private(scope:)` | `scope` argument on the `@private` directive |
22342251

2235-
All examples below will assume the following schema:
2252+
The table above shows an example of a *schema coordinate* for every kind of
2253+
*schema element* based on the schema below.
22362254

2237-
```graphql example
2238-
directive @private(scope: String!) on FIELD
2239-
2240-
scalar DateTime
2241-
2242-
input ReviewInput {
2243-
content: String
2244-
author: String
2245-
businessId: String
2246-
}
2247-
2248-
interface Address {
2249-
city: String
2250-
}
2251-
2252-
type User implements Address {
2253-
name: String
2254-
reviewCount: Int
2255-
friends: [User]
2256-
email: String @private(scope: "loggedIn")
2257-
city: String
2258-
}
2259-
2260-
type Business implements Address {
2261-
name: String
2262-
address: String
2263-
rating: Int
2264-
city: String
2265-
reviews: [Review]
2266-
createdAt: DateTime
2255+
```graphql
2256+
type Query {
2257+
searchBusiness(criteria: SearchCriteria!): [Business]
22672258
}
22682259

2269-
type Review {
2270-
content: String
2271-
author: User
2272-
business: Business
2273-
createdAt: DateTime
2260+
input SearchCriteria {
2261+
name: String
2262+
filter: SearchFilter
22742263
}
22752264

2276-
union Entity = User | Business | Review
2277-
22782265
enum SearchFilter {
2279-
OPEN_NOW
2280-
DELIVERS_TAKEOUT
2281-
VEGETARIAN_MENU
2282-
}
2283-
2284-
type Query {
2285-
searchBusiness(name: String!, filter: SearchFilter): Business
2266+
OPEN_NOW
2267+
DELIVERS_TAKEOUT
2268+
VEGETARIAN_MENU
22862269
}
22872270

2288-
type Mutation {
2289-
addReview(input: ReviewInput!): Review
2271+
type Business {
2272+
id: ID
2273+
name: String
2274+
email: String @private(scope: "loggedIn")
22902275
}
2291-
```
2292-
2293-
The following table shows examples of Schema Coordinates for elements in the
2294-
schema above:
2295-
2296-
| Schema Coordinate | Description |
2297-
| ------------------------------ | ------------------------------------------------------------------- |
2298-
| `Business` | `Business` type |
2299-
| `User.name` | `name` field on the `User` type |
2300-
| `Query.searchBusiness(name:)` | `name` argument on the `searchBusiness` field on the `Query` type |
2301-
| `SearchFilter` | `SearchFilter` enum |
2302-
| `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the`SearchFilter` enum |
2303-
| `@private` | `@private` directive definition |
2304-
| `@private(scope:)` | `scope` argument on the `@private` directive definition |
2305-
| `Address` | `Address` interface |
2306-
| `Address.city` | `city` field on the `Address` interface |
2307-
| `ReviewInput` | `ReviewInput` input object type |
2308-
| `ReviewInput.author` | `author` input field on the `ReviewInput` input object type |
2309-
| `Entity` | `Entity` union definition |
2310-
| `DateTime` | Custom `DateTime` scalar type |
2311-
| `String` | Built-in `String` scalar type |
2312-
2313-
Schema Coordinates are always unique. Each type, field, argument, enum value, or
2314-
directive may be referenced by exactly one possible Schema Coordinate.
23152276

2316-
For example, the following is *not* a valid Schema Coordinate:
2317-
2318-
```graphql counter-example
2319-
Entity.Business
2277+
directive @private(scope: String!) on FIELD
23202278
```
2321-
2322-
In this counter example, `Entity.Business` is redundant since `Business` already
2323-
uniquely identifies the Business type. Such redundancy is disallowed by this
2324-
spec - every type, field, field argument, enum value, directive, and directive
2325-
argument has exactly one canonical Schema Coordinate.

0 commit comments

Comments
 (0)