Sha256: 6e687abcb7c2cce50b29b708e2b48f92b3efe132acdbdea4d192a65e315edb22

Contents?: true

Size: 1.53 KB

Versions: 45

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require "spec_helper"
require './lib/graphql/upgrader/schema.rb'

describe GraphQL::Upgrader::Schema do
  def upgrade(old)
    GraphQL::Upgrader::Schema.new(old).upgrade
  end

  it 'updates the definition' do
    old = %{
      StarWarsSchema = GraphQL::Schema.define do
      end
    }
    new = %{
      class StarWarsSchema < GraphQL::Schema
      end
    }

    assert_equal upgrade(old), new
  end

  it 'updates the resolve_type' do
    old = %{
      StarWarsSchema = GraphQL::Schema.define do
        resolve_type ->(obj, ctx) do
          nil
        end
      end
    }
    new = %{
      class StarWarsSchema < GraphQL::Schema
        def self.resolve_type(obj, ctx)
          nil
        end
      end
    }

    assert_equal upgrade(old), new
  end

  it 'updates the object_from_id' do
    old = %{
      StarWarsSchema = GraphQL::Schema.define do
        object_from_id ->(id, ctx) do
          nil
        end
      end
    }
    new = %{
      class StarWarsSchema < GraphQL::Schema
        def self.object_from_id(id, ctx)
          nil
        end
      end
    }

    assert_equal upgrade(old), new
  end

  it 'updates the id_from_object' do
    old = %{
      StarWarsSchema = GraphQL::Schema.define do
        id_from_object -> (object, type_definition, ctx) do
          nil
        end
      end
    }
    new = %{
      class StarWarsSchema < GraphQL::Schema
        def self.id_from_object(object, type_definition, ctx)
          nil
        end
      end
    }

    assert_equal upgrade(old), new
  end


end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.11 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.10 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.9 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.8 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.7 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.6 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.5 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.4 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.3 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.2 spec/graphql/upgrader/schema_spec.rb
graphql-1.8.17 spec/graphql/upgrader/schema_spec.rb
graphql-1.8.16 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.1 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.0 spec/graphql/upgrader/schema_spec.rb
graphql-1.8.15 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.0.pre4 spec/graphql/upgrader/schema_spec.rb
graphql-1.8.14 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.0.pre3 spec/graphql/upgrader/schema_spec.rb
graphql-1.9.0.pre2 spec/graphql/upgrader/schema_spec.rb