lib/graphql/relay/node.rb in graphql-1.4.3 vs lib/graphql/relay/node.rb in graphql-1.4.4

- old
+ new

@@ -2,28 +2,28 @@ module GraphQL module Relay # Helpers for working with Relay-specific Node objects. module Node # @return [GraphQL::Field] a field for finding objects by their global ID. - def self.field + def self.field(resolve: nil) # We have to define it fresh each time because # its name will be modified and its description # _may_ be modified. GraphQL::Field.define do type(GraphQL::Relay::Node.interface) description("Fetches an object given its ID.") argument(:id, !types.ID, "ID of the object.") - resolve(GraphQL::Relay::Node::FindNode) + resolve(resolve || GraphQL::Relay::Node::FindNode) relay_node_field(true) end end - def self.plural_field + def self.plural_field(resolve: nil) GraphQL::Field.define do type(!types[GraphQL::Relay::Node.interface]) description("Fetches a list of objects given a list of IDs.") argument(:ids, !types[!types.ID], "IDs of the objects.") - resolve(GraphQL::Relay::Node::FindNodes) + resolve(resolve || GraphQL::Relay::Node::FindNodes) relay_nodes_field(true) end end # @return [GraphQL::InterfaceType] The interface which all Relay types must implement