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

Merge latest changes from HEAD: 0.4.18 -> 0.5.0 #2

Merged
merged 76 commits into from
Apr 15, 2016
Merged

Conversation

sogko
Copy link
Owner

@sogko sogko commented Apr 15, 2016

April 2016 Spec

leebyron and others added 30 commits March 7, 2016 12:54
Add test for parseLiteral on ComplexScalar
This proposes a change to how we represent the ability to validate the locations of directives via introspection.

Specifically, this deprecates `onField`, `onFragment`, and `onOperation` in favor of `locations` which is a list of `__DirectiveLocation`.

**Rationale:**

This allows for a more fine-grained validation of directive placement, now you can assert that a directive is allowed on queries but not mutations, or allowed on fragment definitions but not on fragment spreads.

Also, this makes expanding the locations a directive is allowed to be placed easier to do, as future expansions will not affect the introspection API. This should be considered a prereq to #265.

Finally, this is a prereq to a forthcoming RFC to add directives to the type schema language, one of the last missing pieces to represent a full schema using this language. Currently considering something like:

```
directive @Skip(if: Boolean) on FIELD, FRAGMENT_SPREAD, INLINE_FRAGMENT
```

**Drawbacks:**

Any change to the introspection API is a challenge. Especially so for graphql-js which is used as both client tools via Graph*i*QL and as a node.js server.

To account for this, I've left the existing fields as deprecated, and continued to support these deprecated fields in `buildClientSchema`, which is used by Graph*i*QL. While graphql-js will likely continue to expose these deprecated fields for some time to come, the spec itself should not include these fields if this change is reflected.
In response to #27 and SO questions. I don't believe there is "official" documentation (besides in issues and tests) of Promise support in the resolve function. Totally willing to be wrong :)
[RFC] Proposed change to directive location introspection
Fix error message for missing operation
Reference promises for resolve func
This adds directives to schema language and to the utilities that use it (schema parser, and buildASTSchema). Directives are one of the few missing pieces from representing a full schema in the schema language.

Note: the schema language is still experimental, so there is no corresponding change to the spec yet.

DirectiveDefinition :
  - directive @ Name ArgumentsDefinition? on DirectiveLocations

DirectiveLocations :
  - Name
  - DirectiveLocations | Name

Example:

```
directive @Skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

directive @include(if: Boolean!)
  on FIELD
   | FRAGMENT_SPREAD
   | INLINE_FRAGMENT
```
Add named type for user defined resolveType and isTypeOf functions
Updating schema parser to more closely match current state of RFC
This implements the schema definition in the spec proposal in graphql/graphql-spec#90

Adjusts AST, parser, printer, visitor, but also changes the API of buildASTSchema to require a schema definition instead of passing the type names into the function.
Split up the completeValue function
leebyron and others added 28 commits March 24, 2016 17:42
[RFC] Add Schema Definition to IDL.
* Remove redundant falsy check for runtimeType

* Replace silent conversion to null with an invariant and a useful error message

* Add an error message for unexpected return value from resolveType

* Make sure null and undefined mean could not determine type while false or 0 indicates wrong return type
Implements graphql/graphql-spec#162



This alters the "Overlapping Fields Can Be Merged" validation rule to better express return type validation issues.



The existing rule has presented some false-positives in some schema where interfaces with co-variant types are commonly used. The "same return type" check doesn't remove any ambiguity.



Instead what that "same return type" check is attempting to prevent is spreading two fragments (or inline fragments) which have fields with return types where ambiguity would be introduced in the response.



In order to curb false-positives, we later changed this rule such that if two fields were known to never apply simultaneously, then we would skip the remainder of the rule.



```

{

  ... on Person {

    foo: fullName

  }

  ... on Pet {

    foo: petName

  }

}

```



However this can introduce false-negatives!



```

{

  ... on Person {

    foo: birthday {

      bar: year

    }

  }

  ... on Business {

    foo: location {

      bar: street

    }

  }

}

```



In the above example, `data.foo.bar` could be of type `Int` or type `String`, it's ambiguous!



This differing return type breaks some client model implementations (Fragment models) in addition to just being confusing.
@sogko sogko changed the title Merge latest changes from HEAD: 0.4.18 > 0.5.0 Merge latest changes from HEAD: 0.4.18 -> 0.5.0 Apr 15, 2016
@sogko sogko merged commit d29694c into sogko:master Apr 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.