Commit 8ab7706d authored by Patrick Derichs's avatar Patrick Derichs Committed by Alex Kalderimis

Add casting class for ID Type

This introduces a new Scalar type: GlobalID. This represents a
`GlobalID` value, which can be passed to `GitlabSchema.object_from_id`
to load an object.
parent 7af7ba45
# frozen_string_literal: true
module Types
class GlobalIDType < GraphQL::Schema::Scalar
description "A wrapper for GraphQL IDs"
# @param value [GID]
# @return [String]
def self.coerce_result(value, _ctx)
value.to_s
end
# @param value [String]
# @return [GID]
def self.coerce_input(value, _ctx)
GlobalID.parse(value.to_s)
rescue ArgumentError, TypeError
# Invalid input
nil
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment