Sha256: 97e8a53ad9c979201a0fc82987dea54f1b8d9044d31a33c86b678b5c40ba3b93

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

module GraphQL
  class Schema
    class TypeExpression
      def initialize(schema, ast_node)
        @schema = schema
        @ast_node = ast_node
      end

      def type
        @type ||= build_type(@schema, @ast_node)
      end

      private

      def build_type(schema, ast_node)
        if ast_node.is_a?(GraphQL::Language::Nodes::TypeName)
          type_name = ast_node.name
          schema.types[type_name]
        elsif ast_node.is_a?(GraphQL::Language::Nodes::NonNullType)
          ast_inner_type = ast_node.of_type
          build_type(schema, ast_inner_type).to_non_null_type
        elsif ast_node.is_a?(GraphQL::Language::Nodes::ListType)
          ast_inner_type = ast_node.of_type
          build_type(schema, ast_inner_type).to_list_type
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-0.13.0 lib/graphql/schema/type_expression.rb