Class: ElasticGraph::SchemaDefinition::SchemaElements::BuiltInTypes
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaDefinition::SchemaElements::BuiltInTypes
- Defined in:
- elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb
Overview
Defines all built-in GraphQL types provided by ElasticGraph.
Scalar Types
Standard GraphQL Scalars
These are defined by the GraphQL spec.
- Boolean
- Represents
true
orfalse
values. - Float
- Represents signed double-precision fractional values as specified by IEEE 754.
- ID
- Represents a unique identifier that is Base64 obfuscated. It is often used to
refetch an object or as key for a cache. The ID type appears in a JSON response as a
String; however, it is not intended to be human-readable. When expected as an input
type, any string (such as
"VXNlci0xMA=="
) or integer (such as4
) input value will be accepted as an ID. - Int
- Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
- String
- Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text.
Additional ElasticGraph Scalars
ElasticGraph defines these additional scalar types.
- Cursor
- An opaque string value representing a specific location in a paginated connection type.
Returned cursors can be passed back in the next query via the
before
orafter
arguments to continue paginating from that point. - Date
- A date, represented as an ISO 8601 date string.
- DateTime
- A timestamp, represented as an ISO 8601 time string.
- JsonSafeLong
- A numeric type for large integer values that can serialize safely as JSON. While JSON
itself has no hard limit on the size of integers, the RFC-7159 spec mentions that
values outside of the range -9,007,199,254,740,991 (-(2^53) + 1) to 9,007,199,254,740,991
(2^53 - 1) may not be interopable with all JSON implementations. As it turns out, the
number implementation used by JavaScript has this issue. When you parse a JSON string that
contains a numeric value like
4693522397653681111
, the parsed result will contain a rounded value like4693522397653681000
. While this is entirely a client-side problem, we want to preserve maximum compatibility with common client languages. Given the ubiquity of GraphiQL as a GraphQL client, we want to avoid this problem. Our solution is to support two separate types:- This type (
JsonSafeLong
) is serialized as a number, but limits values to the safely serializable range. - The
LongString
type supports long values that use all 64 bits, but serializes as a string rather than a number, avoiding the JavaScript compatibility problems. For more background, see the JavaScriptNumber.MAX_SAFE_INTEGER
docs.
- This type (
- LocalTime
- A local time such as
"23:59:33"
or"07:20:47.454"
without a time zone or offset, formatted based on the partial-time portion of RFC3339. - LongString
- A numeric type for large integer values in the inclusive range -2^63 (-9,223,372,036,854,775,808)
to (2^63 - 1) (9,223,372,036,854,775,807). Note that
LongString
values are serialized as strings within JSON, to avoid interopability problems with JavaScript. If you want a large integer type that serializes within JSON as a number, useJsonSafeLong
. - TimeZone
- An IANA time zone identifier, such as
America/Los_Angeles
orUTC
. For a full list of valid identifiers, see the wikipedia article. - Untyped
- A custom scalar type that allows any type of data, including:
- strings
- numbers
- objects and arrays (nested as deeply as you like)
- booleans
Note: fields of this type are effectively untyped. We recommend it only be used for parts of your schema that can’t be statically typed.
Enum Types
ElasticGraph defines these enum types. Most of these are intended for usage as an input argument, but they could be used as a return type in your schema if they meet your needs.
- DateGroupingGranularity
- Enumerates the supported granularities of a
Date
. - DateGroupingTruncationUnit
- Enumerates the supported truncation units of a
Date
. - DateTimeGroupingGranularity
- Enumerates the supported granularities of a
DateTime
. - DateTimeGroupingTruncationUnit
- Enumerates the supported truncation units of a
DateTime
. - DateTimeUnit
- Enumeration of
DateTime
units. - DateUnit
- Enumeration of
Date
units. - DayOfWeek
- Indicates the specific day of the week.
- DistanceUnit
- Enumerates the supported distance units.
- LocalTimeGroupingTruncationUnit
- Enumerates the supported truncation units of a
LocalTime
. - LocalTimeUnit
- Enumeration of
LocalTime
units. - MatchesQueryAllowedEditsPerTerm
- Enumeration of allowed values for the
matchesQuery: {allowedEditsPerTerm: ...}
filter option.
Object Types
ElasticGraph defines these object types.
- AggregationCountDetail
- Provides detail about an aggregation
count
. - GeoLocation
- Geographic coordinates representing a location on the Earth’s surface.
- PageInfo
- Provides information about the specific fetched page. This implements the
PageInfo
specification from the Relay GraphQL Cursor Connections Specification.