Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port 0.12.3 changes from graphql-js #248

Merged
merged 50 commits into from
Mar 26, 2018
Merged

Port 0.12.3 changes from graphql-js #248

merged 50 commits into from
Mar 26, 2018

Commits on Feb 9, 2018

  1. Configuration menu
    Copy the full SHA
    eb9ac66 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    46816a7 View commit details
    Browse the repository at this point in the history

Commits on Feb 10, 2018

  1. RFC: Block String

    This RFC adds a new form of `StringValue`, the multi-line string, similar to that found in Python and Scala.
    
    A multi-line string starts and ends with a triple-quote:
    
    ```
    """This is a triple-quoted string
    and it can contain multiple lines"""
    ```
    
    Multi-line strings are useful for typing literal bodies of text where new lines should be interpretted literally. In fact, the only escape sequence used is `\"""` and `\` is otherwise allowed unescaped. This is beneficial when writing documentation within strings which may reference the back-slash often:
    
    ```
    """
    In a multi-line string \n and C:\\ are unescaped.
    """
    ```
    
    The primary value of multi-line strings are to write long-form input directly in query text, in tools like GraphiQL, and as a prerequisite to another pending RFC to allow docstring style documentation in the Schema Definition Language.
    
    Ref: graphql/graphql-js#926
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    8747ff8 View commit details
    Browse the repository at this point in the history
  2. Improvements to printing block strings

    ref: graphql/graphql-js#f9e67c403a4667372684ee8c3e82e1f0ba27031b
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    e65638f View commit details
    Browse the repository at this point in the history
  3. RFC: Descriptions as strings

    As discussed in graphql/graphql-spec#90
    
    This proposes replacing leading comment blocks as descriptions in the schema definition language with leading strings (typically block strings).
    
    While I think there is some reduced ergonomics of using a string literal instead of a comment to write descriptions (unless perhaps you are accustomed to Python or Clojure), there are some compelling advantages:
    
    * Descriptions are first-class in the AST of the schema definition language.
    * Comments can remain "ignored" characters.
    * No ambiguity between commented out regions and descriptions.
    
    Specific to this reference implementation, since this is a breaking change and comment descriptions in the experimental SDL have fairly wide usage, I've left the comment description implementation intact and allow it to be enabled via an option. This should help with allowing upgrading with minimal impact on existing codebases and aid in automated transforms.
    
    BREAKING CHANGE: This does not parse descriptions from comments by default anymore and the value of description in Nodes changed from string to StringValueNode
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    022c490 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7705e50 View commit details
    Browse the repository at this point in the history
  5. Support for union types when using buildSchema

    * Adds support for resolving union/interface types when using a generated schema
    * Move resolveType __typename checking into defaultResolveType
    * Clean up existing tests and improve error messages
    
    ref: graphql/graphql-js#947
    
    # Conflicts:
    #	src/Utils/BuildSchema.php
    #	tests/Utils/BuildSchemaTest.php
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    4e26de3 View commit details
    Browse the repository at this point in the history
  6. Add additional number lexing test

    ref: graphql/graphql-js#72421378550cf51b13c6db59b8fc912591fd1a4b
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    98e397c View commit details
    Browse the repository at this point in the history
  7. Remove notes about subscription being experimental

    ref: graphql/graphql-js#bf4a25a33a62280e82680518adc279e34ec816e0
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    1fdb3da View commit details
    Browse the repository at this point in the history
  8. Simplify operationTypes validation

    ref: graphql/graphql-js#999
    
    # Conflicts:
    #	src/Utils/BuildSchema.php
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    17a8c26 View commit details
    Browse the repository at this point in the history
  9. Add warnings for nullable changes

    ref: graphql/graphql-js@db4cfdc
    ref: graphql/graphql-js#1096
    
    # Conflicts:
    #	tests/Utils/FindBreakingChangesTest.php
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    2123946 View commit details
    Browse the repository at this point in the history
  10. Fix parsing of default values in build-schema

     * Generalizes building a value from an AST, since "scalar" could be misleading, and supporting variable values within custom scalar literals can be valuable.
    * Replaces isNullish with isInvalid since `null` is a meaningful value as a result of literal parsing.
    * Provide reasonable default version of 'parseLiteral'
    
    ref: graphql/graphql-js@714ee98
    ref: graphql/graphql-js#903
    
    # Conflicts:
    #	src/Utils/BuildSchema.php
    #	tests/Utils/BuildSchemaTest.php
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    27ce24b View commit details
    Browse the repository at this point in the history
  11. (Potentially Breaking) Allow serializing scalars as null.

    This changes the check for null/undefined to a check for undefined to determine if scalar serialization was successful or not, allowing `null` to be returned from serialize() without indicating error.
    
    This is potentially breaking for any existing custom scalar which returned `null` from `serialize()` to indicate failure. To account for this change, it should either throw an error or return `undefined`.
    
    ref: graphql/graphql-js#1104
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    48c3330 View commit details
    Browse the repository at this point in the history
  12. Remove duplicated code from buildASTSchema and extendSchema

    ref: graphql/graphql-js#1000
    
    BREAKING CHANGE: SchemaBuilder::build() and buildAST() and constructor
    removed the typedecorator, as not needed anymore as library can now resolve
    union and interfaces from generated schemas.
    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    2cbccb8 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    c4f11a5 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    1da3801 View commit details
    Browse the repository at this point in the history
  15. Add Docs

    danez committed Feb 10, 2018
    Configuration menu
    Copy the full SHA
    d6add77 View commit details
    Browse the repository at this point in the history

Commits on Feb 11, 2018

  1. Configuration menu
    Copy the full SHA
    0c32982 View commit details
    Browse the repository at this point in the history
  2. Update to match SDL changes

    This changes the parsing grammar and validation rules to more correctly implement the current state of the GraphQL SDL proposal (graphql/graphql-spec#90)
    
    ref: graphql/graphl-js#1102
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    d70a9a5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    58453c3 View commit details
    Browse the repository at this point in the history
  4. Validation: improving overlapping fields quality

    This improves the overlapping fields validation performance and improves error reporting quality by separating the concepts of checking fields "within" a single collection of fields from checking fields "between" two different collections of fields. This ensures for deeply overlapping fields that nested fields are not checked against each other repeatedly. Extending this concept further, fragment spreads are no longer expanded inline before looking for conflicts, instead the fields within a fragment are compared to the fields with the selection set which contained the referencing fragment spread.
    
    e.g.
    
    ```graphql
    {
      same: a
      same: b
      ...X
    }
    
    fragment X on T {
      same: c
      same: d
    }
    ```
    
    In the above example, the initial query body is checked "within" so `a` is compared to `b`. Also, the fragment `X` is checked "within" so `c` is compared to `d`. Because of the fragment spread, the query body and fragment `X` are checked "between" so that `a` and `b` are each compared to `c` and `d`. In this trivial example, no fewer checks are performed, but in the case where fragments are referenced multiple times, this reduces the overall number of checks (regardless of memoization).
    
    **BREAKING**: This can change the order of fields reported when a conflict arises when fragment spreads are involved. If you are checking the precise output of errors (e.g. for unit tests), you may find existing errors change from `"a" and "c" are different fields` to `"c" and "a" are different fields`.
    
    From a perf point of view, this is fairly minor as the memoization "PairSet" was already keeping these repeated checks from consuming time, however this will reduce the number of memoized hits because of the algorithm improvement.
    
    From an error reporting point of view, this reports nearest-common-ancestor issues when found in a fragment that comes later in the validation process. I've added a test which fails with the existing impl and now passes, as well as changed a comment.
    
    This also fixes an error where validation issues could be missed because of an over-eager memoization. I've also modified the `PairSet` to be aware of both forms of memoization, also represented by a previously failing test.
    
    ref: graphql/graphql-js#386
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    7b05673 View commit details
    Browse the repository at this point in the history
  5. Fix infinite loop on invalid queries in OverlappingFields

    `OverlappingFieldsCanBeMerged` would infinite loop when passed something like
    
    ```graphql
    fragment A on User {
      name
      ...A
    }
    ```
    
    It's not `OverlappingFieldsCanBeMerged`'s responsibility to detect that validation error, but we still would ideally avoid infinite looping.
    
    This detects that case, and pretends that the infinite spread wasn't there for the purposes of this validation step.
    
    Also, by memoizing and checking for self-references this removes duplicate reports.
    
    ref: graphql/graphql-js#1111
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    6e358eb View commit details
    Browse the repository at this point in the history
  6. Improve introspection types + new getIntrospectionQuery()

    This adds a new function `getIntrospectionQuery()` which allows for some minor configuration over the resulting query text: to exclude descriptions if your use case does not require them.
    
    ref: graphql/graphql-js#1113
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    ff63e07 View commit details
    Browse the repository at this point in the history
  7. Read-only AST types

    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    74854d5 View commit details
    Browse the repository at this point in the history
  8. SDL Spec changes

    This adds the recent changes to the SDL proposal.
    
    ref: graphql/graphql-js#1117
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    b5106a0 View commit details
    Browse the repository at this point in the history
  9. Allow constructing GraphQLError with single node.

    A common case is encountering an error which blames to a single AST node. Ensure the GraphQLError constructor can handle this case.
    
    ref: graphql/graphql-js#1123
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    0c984a8 View commit details
    Browse the repository at this point in the history
  10. Include test that printSchema includes non-spec directives.

    ref: graphql/graphql-js@007407d
    
    Also fixes expected <-> actual in this testfile
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    481cdc9 View commit details
    Browse the repository at this point in the history
  11. Fix unhandled error when parsing custom scalar literals.

    This factors out the enum value validation from scalar value validation and ensures the same try/catch is used in isValidLiteralValue as isValidPHPValue and protecting from errors in valueFromAST.
    ref: graphql/graphql-js#1126
    danez committed Feb 11, 2018
    Configuration menu
    Copy the full SHA
    f661f38 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2018

  1. New: printError()

    Lifted from / inspired by a similar change in graphql/graphql-js#722, this creates a new function `printError()` (and uses it as the implementation for `GraphQLError#toString()`) which prints location information in the context of an error.
    
    This is moved from the syntax error where it used to be hard-coded, so it may now be used to format validation errors, value coercion errors, or any other error which may be associated with a location.
    
    ref: graphql/graphql-js
    
    BREAKING CHANGE: The SyntaxError message does not contain the codeframe anymore and only the message, (string) $error will print the codeframe.
    danez committed Feb 12, 2018
    Configuration menu
    Copy the full SHA
    15374a3 View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2018

  1. Validate schema root types and directives

    This moves validation out of GraphQLSchema's constructor (but not yet from other type constructors), which is responsible for root type validation and interface implementation checking.
    
    Reduces time to construct GraphQLSchema significantly, shifting the time to validation.
    
    This also allows for much looser rules within the schema builders, which implicitly validate while trying to adhere to flow types. Instead we use any casts to loosen the rules to defer that to validation where errors can be richer.
    
    This also loosens the rule that a schema can only be constructed if it has a query type, moving that to validation as well. That makes flow typing slightly less nice, but allows for incremental schema building which is valuable
    
    ref: graphql/graphql-js#1124
    danez committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    06c6c4b View commit details
    Browse the repository at this point in the history
  2. Fix printError/locations for multiple nodes.

    If a GraphQLError represents multiple nodes across files (could happen for validation across multiple parsed files) then the reported locations and printError output can be incorrect for the second node. This ensures locations are derived from nodes whenever possible to get correct location and amends comment documentation.
    ref: graphql/graphql-js#1131
    danez committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    cf27634 View commit details
    Browse the repository at this point in the history
  3. Always extract extensions from the original error if possible

    ref: graphql/graphql-js#2d08496720088dbe65ebea312c8526bd48fb8ee8
    danez committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    6d45a22 View commit details
    Browse the repository at this point in the history
  4. Preserve original coercion errors, improve error quality.

    This is a fairly major refactoring of coerceValue which returns an Either so it can return a complete collection of errors. This allows originalError to be preserved for scalar coercion errors and ensures *all* errors are represented in the response.
    
    This had a minor change to the logic in execute / subscribe to allow for buildExecutionContext to abrupt complete with multiple errors.
    
    ref: graphql/graphql-js#1133
    danez committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    60df83f View commit details
    Browse the repository at this point in the history
  5. Better Predicates

    Introduces new assertion functions for each kind of type mirroring the existing ones for the higher order types.
    
    ref: graphql/graphql-js#1137
    danez committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    9387548 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    50cbfb4 View commit details
    Browse the repository at this point in the history
  7. Address recent SDL spec changes

    This should be the last set of spec changes for a standardized SDL
    
    ref: graphql/graphql-js#1139
    danez committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    6d08c34 View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2018

  1. Move schema validation into separate step (type constructors)

    This is the second step of moving work from type constructors to the schema validation function.
    
    ref: graphql/graphql-js#1132
    danez committed Feb 15, 2018
    Configuration menu
    Copy the full SHA
    97e8a9e View commit details
    Browse the repository at this point in the history
  2. Robust type info

    There are possibilities for errors during validation if a schema is not valid when provided to TypeInfo. Most checks for validity existed, but some did not. This asks flow to make those checks required and adds the remaining ones. Important now that we allow construction of invalid schema.
    
    ref: graphql/graphql-js#1143
    danez committed Feb 15, 2018
    Configuration menu
    Copy the full SHA
    fde7df5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    949b853 View commit details
    Browse the repository at this point in the history
  4. Update some validators to latest upstream version

    This includes:
    graphql/graphql-js#1147
    graphql/graphql-js#355
    
    This also fixes two bugs in the Schema
     - types that were not found where still added to the typeMap
     - InputObject args should not be searched for types.
    danez committed Feb 15, 2018
    Configuration menu
    Copy the full SHA
    1752087 View commit details
    Browse the repository at this point in the history
  5. Validate literals in a single rule with finer precision

    This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function `isValidLiteralValue`. To reduce breaking scope, this does not remove that utility even though it's no longer used directly within the library. Since the default values rule included another validation rule that rule was renamed to a more apt "variable default value allowed".
    
    This also includes the original errors from custom scalars in the validation error output, solving the remainder of graphql/graphql-js#821.
    
    ref: graphql/graphql-js#1144
    danez committed Feb 15, 2018
    Configuration menu
    Copy the full SHA
    58e0c7a View commit details
    Browse the repository at this point in the history
  6. Fix path argument. Enchance visit test to validate all arguments

    ref: graphl/graphql-js#1149
    danez committed Feb 15, 2018
    Configuration menu
    Copy the full SHA
    ddfeee3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d71b45d View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2018

  1. Configuration menu
    Copy the full SHA
    48c5e64 View commit details
    Browse the repository at this point in the history
  2. Add suggestions for invalid values

    For misspelled enums or field names, these suggestions can be helpful.
    
    This also changes the suggestions algorithm to better detect case-sensitivity mistakes, which are common
    
    ref: graphql/graphql-js#1153
    danez committed Feb 16, 2018
    Configuration menu
    Copy the full SHA
    d92a2da View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dc6e814 View commit details
    Browse the repository at this point in the history
  4. Skip test on PHP < 7

    danez committed Feb 16, 2018
    Configuration menu
    Copy the full SHA
    5e7cf2a View commit details
    Browse the repository at this point in the history
  5. Update docs

    danez committed Feb 16, 2018
    Configuration menu
    Copy the full SHA
    61fe317 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f9a366e View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2018

  1. Configuration menu
    Copy the full SHA
    3e067cc View commit details
    Browse the repository at this point in the history