Sha256: 856cfeca0f3edeeed576f770ca84da220a61490b47bc46113ed52d25ab7dfcba

Contents?: true

Size: 1.43 KB

Versions: 28

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Schema::IntrospectionSystem do
  describe "custom introspection" do
    it "serves custom fields on types" do
      res = Jazz::Schema.execute("{ __schema { isJazzy } }")
      assert_equal true, res["data"]["__schema"]["isJazzy"]
    end

    it "serves overridden fields on types" do
      res = Jazz::Schema.execute(%|{ __type(name: "Ensemble") { name } }|)
      assert_equal "ENSEMBLE", res["data"]["__type"]["name"]
    end

    it "serves custom entry points"  do
      res = Jazz::Schema.execute("{ __classname }", root_value: Set.new)
      assert_equal "Set", res["data"]["__classname"]
    end

    it "serves custom dynamic fields" do
      res = Jazz::Schema.execute("{ nowPlaying { __typename __typenameLength __astNodeClass } }")
      assert_equal "Ensemble", res["data"]["nowPlaying"]["__typename"]
      assert_equal 8, res["data"]["nowPlaying"]["__typenameLength"]
      assert_equal "GraphQL::Language::Nodes::Field", res["data"]["nowPlaying"]["__astNodeClass"]
    end

    it "doesn't affect other schemas" do
      res = Dummy::Schema.execute("{ __schema { isJazzy } }")
      assert_equal 1, res["errors"].length

      res = Dummy::Schema.execute("{ __classname }", root_value: Set.new)
      assert_equal 1, res["errors"].length

      res = Dummy::Schema.execute("{ ensembles { __typenameLength } }")
      assert_equal 1, res["errors"].length
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.17 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.16 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.15 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.14 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.13 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.12 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.11 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.10 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.9 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.8 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.7 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.6 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.5 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.4 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.3 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.2 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.1 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.0 spec/graphql/schema/introspection_system_spec.rb
graphql-1.8.0.pre11 spec/graphql/schema/introspection_system_spec.rb