Skip to content

Commit

Permalink
Merge pull request #157 from facebook/re-chapter
Browse files Browse the repository at this point in the history
Minor adjustments to chapter formatting
  • Loading branch information
leebyron committed Mar 22, 2016
2 parents 3b08851 + 716bc0a commit bb45a6f
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 30 deletions.
50 changes: 30 additions & 20 deletions spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Note: GraphQL intentionally does not consider Unicode "Zs" category characters
as white-space, avoiding misinterpretation by text editors and source
control tools.


### Line Terminators

LineTerminator ::
Expand Down Expand Up @@ -186,7 +187,7 @@ multiple operations to a GraphQL service, the name of the desired operation to
be executed must also be provided.


### Operations
## Operations

OperationDefinition :
- OperationType Name? VariableDefinitions? Directives? SelectionSet
Expand Down Expand Up @@ -231,7 +232,7 @@ For example, this unnamed query operation is written via query shorthand.
Note: many examples below will use the query short-hand syntax.


### Selection Sets
## Selection Sets

SelectionSet : { Selection+ }

Expand All @@ -255,7 +256,8 @@ under-fetching data.
In this query, the `id`, `firstName`, and `lastName` fields form a selection
set. Selection sets may also contain fragment references.

### Fields

## Fields

Field : Alias? Name Arguments? Directives? SelectionSet?

Expand Down Expand Up @@ -312,7 +314,7 @@ unique identifier.
```


### Arguments
## Arguments

Arguments : ( Argument+ )

Expand Down Expand Up @@ -367,7 +369,7 @@ These two queries are semantically identical:
```


### Field Alias
## Field Alias

Alias : Name :

Expand Down Expand Up @@ -427,7 +429,7 @@ A field's response key is its alias if an alias is provided, and it is
otherwise the field's name.


### Fragments
## Fragments

FragmentSpread : ... FragmentName Directives?

Expand Down Expand Up @@ -517,7 +519,8 @@ fragment standardProfilePic on User {
The queries `noFragments`, `withFragments`, and `withNestedFragments` all
produce the same response object.

#### Type Conditions

### Type Conditions

TypeCondition : on NamedType

Expand Down Expand Up @@ -576,7 +579,8 @@ will be present and `friends` will not.
}
```

#### Inline Fragments

### Inline Fragments

InlineFragment : ... TypeCondition? Directives? SelectionSet

Expand Down Expand Up @@ -622,7 +626,7 @@ query inlineFragmentNoType($expandedInfo: Boolean) {
```


### Input Values
## Input Values

Value[Const] :
- [~Const] Variable
Expand All @@ -640,7 +644,8 @@ input values can be scalars, enumeration values, lists, or input objects.
If not defined as constant (for example, in {DefaultValue}), input values can be
specified as a variable. List and inputs objects may also contain variables (unless defined to be constant).

#### Int Value

### Int Value

IntValue :: IntegerPart

Expand All @@ -656,7 +661,8 @@ NonZeroDigit :: Digit but not `0`

An Int number is specified without a decimal point or exponent (ex. `1`).

#### Float Value

### Float Value

FloatValue ::
- IntegerPart FractionalPart
Expand All @@ -674,13 +680,15 @@ Sign :: one of + -
A Float number includes either a decimal point (ex. `1.0`) or an exponent
(ex. `1e50`) or both (ex. `6.0221413e23`).

#### Boolean Value

### Boolean Value

BooleanValue : one of `true` `false`

The two keywords `true` and `false` represent the two boolean values.

#### String Value

### String Value

StringValue ::
- `""`
Expand Down Expand Up @@ -728,7 +736,7 @@ StringCharacter :: \ EscapedCharacter
* Return the character value of {EscapedCharacter}.


#### Enum Value
### Enum Value

EnumValue : Name but not `true`, `false` or `null`

Expand All @@ -740,7 +748,8 @@ necessary to supply an enumeration type name in the literal.
An enum value cannot be "null" in order to avoid confusion. GraphQL
does not supply a value literal to represent the concept {null}.

#### List Value

### List Value

ListValue[Const] :
- [ ]
Expand All @@ -766,7 +775,8 @@ ListValue : [ Value+ ]
* Append {value} to {inputList}.
* Return {inputList}

#### Input Object Values

### Input Object Values

ObjectValue[Const] :
- { }
Expand Down Expand Up @@ -814,7 +824,7 @@ ObjectValue : { ObjectField+ }
* Return {inputObject}


### Variables
## Variables

Variable : $ Name

Expand Down Expand Up @@ -857,7 +867,7 @@ size `60` width:
}
```

#### Variable use within Fragments
** Variable use within Fragments **

Query variables can be used within fragments. Query variables have global scope
with a given operation, so a variable used within a fragment must be declared
Expand All @@ -866,7 +876,7 @@ a variable is referenced in a fragment and is included by an operation that does
not define that variable, the operation cannot be executed.


### Input Types
## Input Types

Type :
- NamedType
Expand Down Expand Up @@ -907,7 +917,7 @@ Type : Type !
* Return {type}


### Directives
## Directives

Directives : Directive+

Expand Down
29 changes: 22 additions & 7 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ any built in types (including Scalar and Introspection types).
All directives within a GraphQL schema must have unique names. A directive
and a type may share the same name, since there is no ambiguity between them.


## Types

The fundamental unit of any GraphQL Schema is the type. There are eight kinds
Expand Down Expand Up @@ -59,6 +60,7 @@ Finally, oftentimes it is useful to provide complex structs as inputs to
GraphQL queries; the `Input Object` type allows the schema to define exactly
what data is expected from the client in these queries.


### Scalars

As expected by the name, a scalar represents a primitive value in GraphQL.
Expand Down Expand Up @@ -113,13 +115,14 @@ and floating-point values, they are interpreted as an integer input value if
they have an empty fractional part (ex. `1.0`) and otherwise as floating-point
input value.

#### Built-in Scalars
**Built-in Scalars**

GraphQL provides a basic set of well-defined Scalar types. A GraphQL server
should support all of these types, and a GraphQL server which provide a type by
these names must adhere to the behavior described below.

##### Int

#### Int

The Int scalar type represents a signed 32-bit numeric non-fractional values.
Response formats that support a 32-bit integer or a number type should use
Expand All @@ -143,7 +146,8 @@ Note: Numeric integer values larger than 32-bit should either use String or a
custom-defined Scalar type, as not all platforms and transports support
encoding integer numbers larger than 32-bit.

##### Float

#### Float

The Float scalar type represents signed double-precision fractional values
as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).
Expand All @@ -165,7 +169,8 @@ other input values, including strings with numeric content, must raise a query
error indicating an incorrect type. If the integer input value represents a
value not representable by IEEE 754, a query error should be raised.

##### String

#### String

The String scalar type represents textual data, represented as UTF-8 character
sequences. The String type is most often used by GraphQL to represent free-form
Expand All @@ -185,7 +190,8 @@ When expected as an input type, only valid UTF-8 string input values are
accepted. All other input values must raise a query error indicating an
incorrect type.

##### Boolean

#### Boolean

The Boolean scalar type represents `true` or `false`. Response formats should
use a built-in boolean type if supported; otherwise, they should use their
Expand All @@ -202,7 +208,8 @@ otherwise they must raise a field error. Examples of this may include returning
When expected as an input type, only boolean input values are accepted. All
other input values must raise a query error indicating an incorrect type.

##### ID

#### ID

The ID scalar type represents a unique identifier, often used to refetch an
object or as key for a cache. The ID type is serialized in the same way as
Expand Down Expand Up @@ -444,6 +451,7 @@ executor, so this is covered in that section of the spec.

Objects are never valid inputs.


#### Object Field Arguments

Object fields are conceptually functions which yield values. Occasionally object
Expand Down Expand Up @@ -484,13 +492,15 @@ May yield the result:

The type of an object field argument can be any Input type.


#### Object Field deprecation

Fields in an object may be marked as deprecated as deemed necessary by the
application. It is still legal to query for these fields (to ensure existing
clients are not broken by the change), but the fields should be appropriately
treated in documentation and tooling.


#### Object type validation

Object types have the potential to be invalid if incorrectly defined. This set
Expand Down Expand Up @@ -618,6 +628,7 @@ is the same as the result coercion of the object.

Interfaces are never valid inputs.


#### Interface type validation

Interface types have the potential to be invalid if incorrectly defined.
Expand Down Expand Up @@ -699,6 +710,7 @@ same as the result coercion of the object.

Unions are never valid inputs.


#### Union type validation

Union types have the potential to be invalid if incorrectly defined.
Expand Down Expand Up @@ -793,6 +805,7 @@ the only item in the list. This is to allow inputs that accept a "var args"
to declare their input type as a list; if only one argument is passed (a common
case), the client can just pass that value rather than constructing the list.


### Non-Null

By default, all types in GraphQL are nullable; the {null} value is a valid
Expand Down Expand Up @@ -858,6 +871,7 @@ engine supports.

GraphQL implementations should provide the `@skip` and `@include` directives.


### @skip

The `@skip` directive may be provided for fields, fragment spreads, and
Expand All @@ -873,6 +887,7 @@ query myQuery($someTest: Boolean) {
}
```


### @include

The `@include` directive may be provided for fields, fragment spreads, and
Expand All @@ -891,7 +906,7 @@ query myQuery($someTest: Boolean) {
In the case that both the `@skip` and `@include` directives are provided in the same context, the field or fragment *must* be queried only if the `@skip` condition is false *and* the `@include` condition is true. Stated conversely, the field/fragment must *not* be queried if either the `@skip` condition is true *or* the `@include` condition is false.


## Starting types
## Initial types

A GraphQL schema includes types, indicating where query and mutation
operations start. This provides the initial entry points into the
Expand Down
Loading

0 comments on commit bb45a6f

Please sign in to comment.