Sha256: 4f0af733d2f9384cc17fc4929dd5fd97576906be0211eb52d77b4e609c9d4da7
Contents?: true
Size: 1.13 KB
Versions: 8
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' describe GraphQL::InterfaceType do let(:interface) { EdibleInterface } it 'has possible types' do assert_equal([CheeseType, MilkType], interface.possible_types) end it 'resolves types for objects' do assert_equal(CheeseType, interface.resolve_type(CHEESES.values.first)) assert_equal(MilkType, interface.resolve_type(MILKS.values.first)) end describe 'query evaluation' do let(:query) { GraphQL::Query.new(DummySchema, query_string, context: {}, variables: {"cheeseId" => 2})} let(:result) { query.result } let(:query_string) {%| query fav { favoriteEdible { fatContent } } |} it 'gets fields from the type for the given object' do expected = {"data"=>{"favoriteEdible"=>{"fatContent"=>0.04}}} assert_equal(expected, result) end end describe '#resolve_type' do let(:interface) { GraphQL::InterfaceType.define do resolve_type -> (object) { return :custom_resolve } end } it 'can be overriden in the definition' do assert_equal(interface.resolve_type(123), :custom_resolve) end end end
Version data entries
8 entries across 8 versions & 1 rubygems