Sha256: de204459300ec20a6a5dc0c409aef6a360f19eb6bbbe4217ce3e6deb6d5c4b5e

Contents?: true

Size: 770 Bytes

Versions: 9

Compression:

Stored size: 770 Bytes

Contents

require 'spec_helper'

describe GraphQL::Relay::Node do
  describe 'NodeField' do
    it 'finds objects by id' do
      global_id = GraphQL::Relay::Node.to_global_id("Ship", "1")
      result = query(%|{node(id: "#{global_id}") { id, ... on Ship { name } }}|)
      expected = {"data" => {
        "node" => {
          "id" =>   global_id,
          "name" => "X-Wing"
        }
      }}
      assert_equal(expected, result)
    end
  end

  describe 'to_global_id / from_global_id ' do
    it 'Converts typename and ID to and from ID' do
      global_id = GraphQL::Relay::Node.to_global_id("SomeType", "123")
      type_name, id = GraphQL::Relay::Node.from_global_id(global_id)
      assert_equal("SomeType", type_name)
      assert_equal("123", id)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
graphql-relay-0.3.6 spec/graphql/relay/node_spec.rb
graphql-relay-0.3.5 spec/graphql/relay/node_spec.rb
graphql-relay-0.3.4 spec/graphql/relay/node_spec.rb
graphql-relay-0.3.3 spec/graphql/relay/node_spec.rb
graphql-relay-0.3.2 spec/graphql/relay/node_spec.rb
graphql-relay-0.3.1 spec/graphql/relay/node_spec.rb
graphql-relay-0.3.0 spec/graphql/relay/node_spec.rb
graphql-relay-0.2.0 spec/graphql/relay/node_spec.rb
graphql-relay-0.1.0 spec/graphql/relay/node_spec.rb