Sha256: 1ff5004cae610be8ef53244e84a38c0c8ac1ccaa89a2a1df3fbaefb979043150

Contents?: true

Size: 571 Bytes

Versions: 41

Compression:

Stored size: 571 Bytes

Contents

# frozen_string_literal: true

module Platform
  module Scalars
    DateTime = GraphQL::ScalarType.define do
      name "DateTime"
      description "An ISO-8601 encoded UTC date string."

      # rubocop:disable Layout/SpaceInLambdaLiteral
      coerce_input -> (value, context) do
        begin
          Time.iso8601(value)
        rescue ArgumentError, ::TypeError
        end
      end
      # rubocop:enable Layout/SpaceInLambdaLiteral

      coerce_result ->(value, context) do
        return nil unless value
        value.utc.iso8601
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.11 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.10 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.9 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.8 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.7 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.6 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.5 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.4 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.3 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.2 spec/fixtures/upgrader/date_time.original.rb
graphql-1.8.17 spec/fixtures/upgrader/date_time.original.rb
graphql-1.8.16 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.1 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.0 spec/fixtures/upgrader/date_time.original.rb
graphql-1.8.15 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.0.pre4 spec/fixtures/upgrader/date_time.original.rb
graphql-1.8.14 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.0.pre3 spec/fixtures/upgrader/date_time.original.rb
graphql-1.9.0.pre2 spec/fixtures/upgrader/date_time.original.rb