Sha256: 81de86bb4341d22fa1717c3fdb6512c903239fbc811c839070b423e1f945a6f3

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

module GraphitiGql
  class Schema
    class PreciseDatetime < GraphQL::Types::ISO8601DateTime
      self.time_precision = 6
    end

    GQL_TYPE_MAP = {
      integer_id: String,
      string: String,
      uuid: String,
      integer: Integer,
      big_integer: GraphQL::Types::BigInt,
      float: Float,
      boolean: GraphQL::Schema::Member::GraphQLTypeNames::Boolean,
      date: GraphQL::Types::ISO8601Date,
      datetime: GraphQL::Types::ISO8601DateTime,
      precise_datetime: PreciseDatetime,
      hash: GraphQL::Types::JSON,
      array: [GraphQL::Types::JSON],
      array_of_strings: [String],
      array_of_integers: [Integer],
      array_of_floats: [Float],
      array_of_dates: [GraphQL::Types::ISO8601Date],
      array_of_datetimes: [GraphQL::Types::ISO8601DateTime],
      array_of_precise_datetimes: [PreciseDatetime]
    }

    class RelayConnectionExtension < GraphQL::Schema::Field::ConnectionExtension
      def resolve(object:, arguments:, context:)
        next_args = arguments.dup
        yield(object, next_args, arguments)
      end
    end

    def self.registry
      Registry.instance
    end

    def self.print
      GraphQL::Schema::Printer.print_schema(GraphitiGql.schema)
    end

    def initialize(resources)
      @resources = resources
    end

    def generate
      klass = Class.new(::GraphQL::Schema)
      klass.query(Query.new(@resources).build)
      klass.use(GraphQL::Batch)
      klass.connections.add(ResponseShim, Connection)
      klass.connections.add(Array, ToManyConnection)
      klass.orphan_types [GraphQL::Types::JSON]
      klass
    end
  end
end





Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphiti_gql-0.2.1 lib/graphiti_gql/schema.rb
graphiti_gql-0.2.0 lib/graphiti_gql/schema.rb