Sha256: c012a1f4b50e09a23b3d6622e36504a14c35185aeca7ef306851a00c9509697f

Contents?: true

Size: 800 Bytes

Versions: 14

Compression:

Stored size: 800 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

14 entries across 14 versions & 1 rubygems

Version Path
graphql-0.12.1 lib/graphql/schema/type_expression.rb
graphql-0.12.0 lib/graphql/schema/type_expression.rb
graphql-0.11.1 lib/graphql/schema/type_expression.rb
graphql-0.11.0 lib/graphql/schema/type_expression.rb
graphql-0.10.9 lib/graphql/schema/type_expression.rb
graphql-0.10.8 lib/graphql/schema/type_expression.rb
graphql-0.10.7 lib/graphql/schema/type_expression.rb
graphql-0.10.6 lib/graphql/schema/type_expression.rb
graphql-0.10.5 lib/graphql/schema/type_expression.rb
graphql-0.10.4 lib/graphql/schema/type_expression.rb
graphql-0.10.3 lib/graphql/schema/type_expression.rb
graphql-0.10.2 lib/graphql/schema/type_expression.rb
graphql-0.10.1 lib/graphql/schema/type_expression.rb
graphql-0.10.0 lib/graphql/schema/type_expression.rb