Sha256: 6b81e2a6cc6d15326b73055cb8f61ef725d4722d0eb3a6c7e211d5fc1003d402

Contents?: true

Size: 1.31 KB

Versions: 12

Compression:

Stored size: 1.31 KB

Contents

require "spec_helper"

describe GraphQL::Language::Generation do
  let(:document) { GraphQL::Language::Parser.parse(query_string) }
  let(:query_string) {%|
    query getStuff($someVar: Int = 1, $anotherVar: [String!]) @skip(if: false) {
      myField: someField(someArg: $someVar, ok: 1.4) @skip(if: $anotherVar) @thing(or: "Whatever")
      anotherField(someArg: [1, 2, 3]) {
        nestedField
        ... moreNestedFields @skip(if: true)
      }
      ... on OtherType @include(unless: false) {
        field(arg: [{key: "value", anotherKey: 0.9, anotherAnotherKey: WHATEVER}])
        anotherField
      }
      ... {
        id
      }
    }
    fragment moreNestedFields on NestedType @or(something: "ok") {
      anotherNestedField
    }
  |}

  describe ".generate" do
    it "generates query string" do
      assert_equal query_string.gsub(/^    /, "").strip, document.to_query_string
    end

    describe "inputs" do
      let(:query_string) {%|
        query {
          field(int: 3, float: 4.7e-24, bool: false, string: "☀︎🏆\\n escaped \\" unicode ¶ /", enum: ENUM_NAME, array: [7, 8, 9], object: {a: [1, 2, 3], b: {c: "4"}}, unicode_bom: "\xef\xbb\xbfquery")
        }
      |}

      it "generate" do
        assert_equal query_string.gsub(/^        /, "").strip, document.to_query_string
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
graphql-0.17.2 spec/graphql/language/generation_spec.rb
graphql-0.17.1 spec/graphql/language/generation_spec.rb
graphql-0.17.0 spec/graphql/language/generation_spec.rb
graphql-0.16.1 spec/graphql/language/generation_spec.rb
graphql-0.16.0 spec/graphql/language/generation_spec.rb
graphql-0.15.3 spec/graphql/language/generation_spec.rb
graphql-0.15.2 spec/graphql/language/generation_spec.rb
graphql-0.14.2 spec/graphql/language/generation_spec.rb
graphql-0.15.1 spec/graphql/language/generation_spec.rb
graphql-0.15.0 spec/graphql/language/generation_spec.rb
graphql-0.14.1 spec/graphql/language/generation_spec.rb
graphql-0.14.0 spec/graphql/language/generation_spec.rb