Sha256: b491b3469c6bf29a5864c085bcfa8a116fa6d45c53c6bf801dfabc33083bacd3
Contents?: true
Size: 871 Bytes
Versions: 3
Compression:
Stored size: 871 Bytes
Contents
# frozen_string_literal: true module GraphQL class Schema # Stores `{ name => type }` pairs for a given schema. # It behaves like a hash except for a couple things: # - if you use `[key]` and that key isn't defined, 💥! # - if you try to define the same key twice, 💥! # # If you want a type, but want to handle the undefined case, use {#fetch}. class TypeMap extend GraphQL::Delegate def_delegators :@storage, :key?, :keys, :values, :to_h, :fetch, :each, :each_value def initialize @storage = {} end def [](key) @storage[key] || raise("No type found for '#{key}'") end def []=(key, value) if @storage.key?(key) raise("Duplicate type definition found for name '#{key}'") else @storage[key] = value end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
graphql-1.6.4 | lib/graphql/schema/type_map.rb |
graphql-1.5.15 | lib/graphql/schema/type_map.rb |
graphql-1.6.3 | lib/graphql/schema/type_map.rb |