Sha256: 65493b202af52cb3c3ec1a77fa35ccb0e2a0cbb6f41e4549fc6372bb03e3da1e
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
module GraphQL module Execution # GraphQL object `{value, type}` can be cast to `other_type` when: # - `type == other_type` # - `type` is a union and it resolves `value` to `other_type` # - `other_type` is a union and `type` is a member # - `type` is an interface and it resolves `value` to `other_type` # - `other_type` is an interface and `type` implements that interface module Typecast # While `value` is exposed by GraphQL as an instance of `current_type`, # should it _also_ be treated as an instance of `potential_type`? # # This is used for checking whether fragments apply to an object. # # @return [Boolean] Can `value` be evaluated as a `potential_type`? def self.compatible?(value, current_type, potential_type, query_ctx) if potential_type == current_type true elsif current_type.kind.union? current_type.resolve_type(value, query_ctx) == potential_type elsif potential_type.kind.union? potential_type.include?(current_type) elsif current_type.kind.interface? current_type.resolve_type(value, query_ctx) == potential_type elsif potential_type.kind.interface? current_type.interfaces.include?(potential_type) else false end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.18.2 | lib/graphql/execution/typecast.rb |