debian-mirror-gitlab/spec/support/graphql/field_inspection.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
605 B
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
module Graphql
class FieldInspection
def initialize(field)
@field = field
end
def nested_fields?
!scalar? && !enum?
end
def scalar?
type.kind.scalar?
end
def enum?
type.kind.enum?
end
def type
@type ||= begin
2022-07-23 23:45:48 +05:30
field_type = @field.type
2021-02-22 17:27:13 +05:30
2022-01-26 12:08:38 +05:30
# The type could be nested. For example `[GraphQL::Types::String]`:
2021-02-22 17:27:13 +05:30
# - List
# - String!
# - String
field_type = field_type.of_type while field_type.respond_to?(:of_type)
field_type
end
end
end
end