README.md in graphql-relay-0.11.2 vs README.md in graphql-relay-0.12.0
- old
+ new
@@ -32,13 +32,15 @@
Global ids (or UUIDs) provide refetching & global identification for Relay.
#### UUID Lookup
-Use `GraphQL::Relay::GlobalNodeIdentification` helper by defining `object_from_id(global_id, ctx)` & `type_from_object(object)`. The resulting `NodeIdentification` object is in your schema _and_ internally by `GraphQL::Relay`.
+Use `GraphQL::Relay::GlobalNodeIdentification` helper by defining `object_from_id(global_id, ctx)` & `type_from_object(object)`. Then, assign the result to `Schema#node_identification` so that it can be used for query execution.
+For example, define a node identification helper:
+
```ruby
NodeIdentification = GraphQL::Relay::GlobalNodeIdentification.define do
# Given a UUID & the query context,
# return the corresponding application object
object_from_id -> (id, ctx) do
@@ -57,10 +59,18 @@
end
end
end
```
+Then assign it to the schema:
+
+```ruby
+MySchema = GraphQL::Schema.new(...)
+# Assign your node identification helper:
+MySchema.node_identification = NodeIdentification
+```
+
#### UUID fields
ObjectTypes in your schema should implement `NodeIdentification.interface` with the `global_id_field` helper, for example:
```ruby
@@ -105,13 +115,17 @@
from_global_id -> (global_id) {
id_parts = global_id.split("/")
type_name = id_parts[0]
id = id_parts[1]
# Return *both*:
- type_name, id
+ [type_name, id]
}
end
+
+# ...
+
+MySchema.node_identification = NodeIdentification
```
`graphql-relay` will use those procs for interacting with global ids.
### Connections
@@ -441,10 +455,9 @@
- http://mgiroux.me/2015/uploading-files-using-relay-with-rails/
## Todo
- `GlobalNodeIdentification.to_global_id` should receive the type name and _object_, not `id`. (Or, maintain the "`type_name, id` in, `type_name, id` out" pattern?)
-- Make GlobalId a property of the schema, not a global
- Reduce duplication in ArrayConnection / RelationConnection
- Improve API for creating edges (better RANGE_ADD support)
- If the new edge isn't a member of the connection's objects, raise a nice error
- Rename `Connection#object` => `Connection#collection` with deprecation