Sha256: 282bba08c5cab30b918f73abae1245b37c853532bcaded8cb7f95ba89f862754

Contents?: true

Size: 1.56 KB

Versions: 30

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::StaticValidation::NoDefinitionsArePresent do
  include StaticValidationHelpers
  describe "when schema definitions are present in the query" do
    let(:query_string) {
      <<-GRAPHQL
      {
        cheese(id: 1) { flavor }
      }

      type Thing {
        stuff: Int
      }

      scalar Date
      GRAPHQL
    }

    it "adds an error" do
      assert_equal 1, errors.length
      err = errors[0]
      assert_equal "Query cannot contain schema definitions", err["message"]
      assert_equal [{"line"=>5, "column"=>7}, {"line"=>9, "column"=>7}], err["locations"]
    end
  end

  describe "when schema extensions are present in the query" do
    let(:query_string) {
      <<-GRAPHQL
      {
        cheese(id: 1) { flavor }
      }

      extend schema {
        subscription: Query
      }

      extend scalar TracingScalar @deprecated
      extend type Dairy @deprecated
      extend interface Edible @deprecated
      extend union Beverage @deprecated
      extend enum DairyAnimal @deprecated
      extend input ResourceOrderType @deprecated
      GRAPHQL
    }

    it "adds an error" do
      assert_equal 1, errors.length
      err = errors[0]
      assert_equal "Query cannot contain schema definitions", err["message"]
      assert_equal [{"line"=>5, "column"=>7},
        {"line"=>9, "column"=>7},
        {"line"=>10, "column"=>7},
        {"line"=>11, "column"=>7},
        {"line"=>12, "column"=>7},
        {"line"=>13, "column"=>7},
        {"line"=>14, "column"=>7}], err["locations"]
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

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