Sha256: fc86c066ce0dca06d0497bae1b92decac4859209b8e00971a1689bf165cd8614

Contents?: true

Size: 923 Bytes

Versions: 48

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

module GraphQL
  module Upgrader
    class Schema
      def initialize(schema)
        GraphQL::Deprecation.warn "#{self.class} will be removed from GraphQL-Ruby 2.0 (but there's no point in using it after you've transformed your code, anyways)"
        @schema = schema
      end

      def upgrade
        transformable = schema.dup

        transformable.sub!(
          /([a-zA-Z_0-9]*) = GraphQL::Schema\.define do/, 'class \1 < GraphQL::Schema'
        )

        transformable.sub!(
          /object_from_id ->\s?\((.*)\) do/, 'def self.object_from_id(\1)'
        )

        transformable.sub!(
          /resolve_type ->\s?\((.*)\) do/, 'def self.resolve_type(\1)'
        )

        transformable.sub!(
          /id_from_object ->\s?\((.*)\) do/, 'def self.id_from_object(\1)'
        )

        transformable
      end

      private

      attr_reader :schema
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
graphql-1.13.23 lib/graphql/upgrader/schema.rb
graphql-1.13.22 lib/graphql/upgrader/schema.rb
graphql-1.13.21 lib/graphql/upgrader/schema.rb
graphql-1.13.20 lib/graphql/upgrader/schema.rb
graphql-1.13.19 lib/graphql/upgrader/schema.rb
graphql-1.13.18 lib/graphql/upgrader/schema.rb
graphql-1.13.17 lib/graphql/upgrader/schema.rb
graphql-1.13.16 lib/graphql/upgrader/schema.rb
graphql-1.13.15 lib/graphql/upgrader/schema.rb
graphql-1.13.14 lib/graphql/upgrader/schema.rb
graphql-1.13.13 lib/graphql/upgrader/schema.rb
graphql_cody-1.13.0 lib/graphql/upgrader/schema.rb
graphql-1.13.12 lib/graphql/upgrader/schema.rb
graphql-1.13.11 lib/graphql/upgrader/schema.rb
graphql-1.13.10 lib/graphql/upgrader/schema.rb
graphql-1.13.9 lib/graphql/upgrader/schema.rb
graphql-1.12.24 lib/graphql/upgrader/schema.rb
graphql-1.13.8 lib/graphql/upgrader/schema.rb
graphql-1.13.7 lib/graphql/upgrader/schema.rb
graphql-1.13.6 lib/graphql/upgrader/schema.rb