|
8 | 8 |
|
9 | 9 | ### Bug fixes
|
10 | 10 |
|
| 11 | +## 0.19.0 (30 Sep 2016) |
| 12 | + |
| 13 | +### Breaking changes |
| 14 | + |
| 15 | +- `GraphQL::Relay::GlobalNodeIdentification` was removed. Its features were moved to `GraphQL::Schema` or `GraphQL::Relay::Node`. The new hooks support more robust & flexible global IDs. #243 |
| 16 | + |
| 17 | + - Relay's `"Node"` interface and `node(id: "...")` field were both moved to `GraphQL::Relay::Node`. To use them in your schema, call `.field` and `.interface`. For example: |
| 18 | + |
| 19 | + ```ruby |
| 20 | + # Adding a Relay-compliant `node` field: |
| 21 | + field :node, GraphQL::Relay::Node.field |
| 22 | + ``` |
| 23 | + |
| 24 | + ```ruby |
| 25 | + # This object type implements Relay's `Node` interface: |
| 26 | + interfaces [GraphQL::Relay::Node.interface] |
| 27 | + ``` |
| 28 | + |
| 29 | + - UUID hooks were renamed and moved to `GraphQL::Schema`. You should define `id_from_object` and `object_from_id` in your `Schema.define { ... }` block. For example: |
| 30 | + |
| 31 | + ```ruby |
| 32 | + MySchema = GraphQL::Schema.define do |
| 33 | + # Fetch an object by UUID |
| 34 | + object_from_id = (id, ctx) -> { |
| 35 | + MyApp::RelayLookup.find(id) |
| 36 | + } |
| 37 | + # Generate a UUID for this object |
| 38 | + id_from_object = (obj, type_defn, ctx) { |
| 39 | + MyApp::RelayLookup.to_id(obj) |
| 40 | + } |
| 41 | + end |
| 42 | + ``` |
| 43 | + |
| 44 | + - The new hooks have no default implementation. To use the previous default, use `GraphQL::Schema::UniqueWithinType`, for example: |
| 45 | + |
| 46 | + ```ruby |
| 47 | + MySchema = GraphQL::Schema.define do |
| 48 | + object_from_id = (id, ctx) -> { |
| 49 | + # Break the id into its parts: |
| 50 | + type_name, object_id = GraphQL::Schema::UniqueWithinType.decode(id) |
| 51 | + # Fetch the identified object |
| 52 | + # ... |
| 53 | + } |
| 54 | +
|
| 55 | + id_from_object = (obj, type_defn, ctx) { |
| 56 | + # Provide the the type name & the object's `id`: |
| 57 | + GraphQL::Schema::UniqueWithinType.encode(type_defn.name, obj.id) |
| 58 | + } |
| 59 | + end |
| 60 | + ``` |
| 61 | + |
| 62 | + If you were using a custom `id_separator`, it's now accepted as an input to `UniqueWithinType`'s methods, as `separator:`. For example: |
| 63 | + |
| 64 | + ```ruby |
| 65 | + # use "---" as a ID separator |
| 66 | + GraphQL::Schema::UniqueWithinType.encode(type_name, object_id, separator: "---") |
| 67 | + GraphQL::Schema::UniqueWithinType.decode(relay_id, separator: "---") |
| 68 | + ``` |
| 69 | + |
| 70 | + - `type_from_object` was previously deprecated and has been replaced by `Schema#resolve_type`. You should define this hook in your schema to return a type definition for a given object: |
| 71 | + |
| 72 | + ```ruby |
| 73 | + MySchema = GraphQL::Schema.define do |
| 74 | + # ... |
| 75 | + resolve_type = -> (obj, ctx) { |
| 76 | + # based on `obj` and `ctx`, |
| 77 | + # figure out which GraphQL type to use |
| 78 | + # and return the type |
| 79 | + } |
| 80 | + end |
| 81 | + ``` |
| 82 | + |
| 83 | + - `Schema#node_identification` has been removed. |
| 84 | + |
| 85 | +- `Argument` default values have been changed to be consistent with `InputObjectType` default values. #267 |
| 86 | + |
| 87 | + Previously, arguments expected GraphQL values as `default_value`s. Now, they expect application values. (`InputObjectType`s always worked this way.) |
| 88 | + |
| 89 | + Consider an enum like this one, where custom values are provided: |
| 90 | + |
| 91 | + ```ruby |
| 92 | + PowerStateEnum = GraphQL::EnumType.define do |
| 93 | + name "PowerState" |
| 94 | + value("ON", value: 1) |
| 95 | + value("OFF", value: 0) |
| 96 | + end |
| 97 | + ``` |
| 98 | + |
| 99 | + __Previously__, enum _names_ were provided as default values, for example: |
| 100 | + |
| 101 | + ```ruby |
| 102 | + field :setPowerState, PowerStateEnum do |
| 103 | + # Previously, the string name went here: |
| 104 | + argument :newValue, default_value: "ON" |
| 105 | + end |
| 106 | + ``` |
| 107 | + |
| 108 | + __Now__, enum _values_ are provided as default values, for example: |
| 109 | + |
| 110 | + ```ruby |
| 111 | + field :setPowerState, PowerStateEnum do |
| 112 | + # Now, use the application value as `default_value`: |
| 113 | + argument :newValue, default_value: 1 |
| 114 | + end |
| 115 | + ``` |
| 116 | + |
| 117 | + Note that if you __don't have custom values__, then there's no change, because the name and value are the same. |
| 118 | + |
| 119 | + Here are types that are affected by this change: |
| 120 | + |
| 121 | + - Custom scalars (previously, the `default_value` was a string, now it should be the application value, eg `Date` or `BigDecimal`) |
| 122 | + - Enums with custom `value:`s (previously, the `default_value` was the name, now it's the value) |
| 123 | +
|
| 124 | + If you can't replace `default_value`s, you can also use a type's `#coerce_input` method to translate a GraphQL value into an application value. For example: |
| 125 | +
|
| 126 | + ```ruby |
| 127 | + # Using a custom scalar, "Date" |
| 128 | + # PREVIOUSLY, provide a string: |
| 129 | + argument :starts_on, DateType, default_value: "2016-01-01" |
| 130 | + # NOW, transform the string into a Date: |
| 131 | + argument :starts_on, DateType, default_value: DateType.coerce_input("2016-01-01") |
| 132 | + ``` |
| 133 | +
|
| 134 | +### New features |
| 135 | +
|
| 136 | +- Support `@deprecated` in the Schema language #275 |
| 137 | +- Support `directive` definitions in the Schema language #280 |
| 138 | +- Use the same introspection field descriptions as `graphql-js` #284 |
| 139 | +
|
| 140 | +### Bug fixes |
| 141 | +
|
| 142 | +- Operation name is no longer present in execution error `"path"` values #276 |
| 143 | +- Default values are correctly dumped & reloaded in the Schema language #267 |
| 144 | +
|
11 | 145 | ## 0.18.15 (20 Sep 2016)
|
12 | 146 |
|
13 | 147 | ### Breaking changes
|
|
0 commit comments