spec/support/star_wars_schema.rb in graphql-relay-0.5.0 vs spec/support/star_wars_schema.rb in graphql-relay-0.5.1
- old
+ new
@@ -37,11 +37,11 @@
field :planet, types.String
end
# Define a connection which will wrap an ActiveRecord::Relation.
# We use an optional block to add fields to the connection type:
-BaseConnection = GraphQL::Relay::RelationConnection.create_type(BaseType) do
+BaseType.define_connection do
field :totalCount do
type types.Int
resolve -> (obj, args, ctx) { obj.object.count }
end
end
@@ -63,11 +63,11 @@
all_ships
}
# You can define arguments here and use them in the connection
argument :nameIncludes, types.String
end
- connection :bases, BaseConnection do
+ connection :bases, BaseType.connection_type do
# Resolve field should return an Array, the Connection
# will do the rest!
resolve -> (obj, args, ctx) {
all_bases = Base.where(id: obj.bases)
if args[:nameIncludes]
@@ -76,11 +76,11 @@
all_bases
}
argument :nameIncludes, types.String
end
- connection :basesClone, BaseConnection
- connection :basesByName, BaseConnection, property: :bases do
+ connection :basesClone, BaseType.connection_type
+ connection :basesByName, BaseType.connection_type, property: :bases do
argument :order, types.String, default_value: "name"
end
end
# Define a mutation. It will also: