Skip to content

Commit

Permalink
Add notes about notational convention, links to Appx A, and shorter a…
Browse files Browse the repository at this point in the history
…lgorithm example

Closes #238
  • Loading branch information
leebyron committed Apr 30, 2018
1 parent bc19747 commit adb11da
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
36 changes: 22 additions & 14 deletions spec/Appendix A -- Notation Conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,25 @@ StringValue :: `"` StringCharacter+ `"`

## Algorithms

This specification describes some algorithms used by the static and runtime semantics, they're defined in the form of a function-like syntax along with a
list of algorithmic steps to take.

For example, this describes if a fragment should be spread into place given a
runtime {objectType} and the fragment's {fragmentType}:

doesFragmentTypeApply(objectType, fragmentType):
* If {fragmentType} is an Object Type:
* if {objectType} and {fragmentType} are the same type, return {true}, otherwise return {false}.
* If {fragmentType} is an Interface Type:
* if {objectType} is an implementation of {fragmentType}, return {true} otherwise return {false}.
* If {fragmentType} is a Union:
* if {objectType} is a possible type of {fragmentType}, return {true} otherwise return {false}.

This specification describes some algorithms used by the static and runtime
semantics, they're defined in the form of a function-like syntax with the
algorithm's name and the arguments it accepts along with a list of algorithmic
steps to take in the order listed. Each step may establish references to other
values, check various conditions, call other algorithms, and eventually return
a value representing the outcome of the algorithm for the provided arguments.

For example, the following example describes an algorithm named {Fibonacci} which
accepts a single argument {number}. The algoritm's steps produce the next number
in the Fibonacci sequence:

Fibonacci(number):
* If {number} is {0}:
* Return {1}.
* If {number} is {1}:
* Return {2}.
* Let {previousNumber} be {number} - {1}.
* Let {previousPreviousNumber} be {number} - {2}.
* Return {Fibonacci(previousNumber)} + {Fibonacci(previousPreviousNumber)}.

Note: Algorithms described in this document are written to be easy to understand.
Implementers are encouraged to include equivalent but optimized implementations.
4 changes: 4 additions & 0 deletions spec/GraphQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ is equivalent. Algorithms described in this document are written to be easy to
understand. Implementers are encouraged to include equivalent but
optimized implementations.

See [Appendix A](#sec-Appendix-Notation-Conventions) for more details
about the definition of algorithms and other notational conventions used in this
document.


**Non-Normative Portions**

Expand Down
3 changes: 3 additions & 0 deletions spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ tokens (indivisible lexical units). These tokens are defined in a lexical
grammar which matches patterns of source characters (defined by a
double-colon `::`).

Note: See [Appendix A](#sec-Appendix-Notation-Conventions) for more details about the definition of lexical and syntactic grammar and other notational conventions
used in this document.


## Source Text

Expand Down

0 comments on commit adb11da

Please # to comment.