scalar.go

 1package graphql
 2
 3// Note: These custom types are meant to be used in queries for now.
 4// But the plan is to switch to using native Go types (string, int, bool, time.Time, etc.).
 5// See https://github.com/shurcooL/githubv4/issues/9 for details.
 6//
 7// These custom types currently provide documentation, and their use
 8// is required for sending outbound queries. However, native Go types
 9// can be used for unmarshaling. Once https://github.com/shurcooL/githubv4/issues/9
10// is resolved, native Go types can completely replace these.
11
12type (
13	// Boolean represents true or false values.
14	Boolean bool
15
16	// Float represents signed double-precision fractional values as
17	// specified by IEEE 754.
18	Float float64
19
20	// ID represents a unique identifier that is Base64 obfuscated. It
21	// is often used to refetch an object or as key for a cache. The ID
22	// type appears in a JSON response as a String; however, it is not
23	// intended to be human-readable. When expected as an input type,
24	// any string (such as "VXNlci0xMA==") or integer (such as 4) input
25	// value will be accepted as an ID.
26	ID interface{}
27
28	// Int represents non-fractional signed whole numeric values.
29	// Int can represent values between -(2^31) and 2^31 - 1.
30	Int int32
31
32	// String represents textual data as UTF-8 character sequences.
33	// This type is most often used by GraphQL to represent free-form
34	// human-readable text.
35	String string
36)
37
38// NewBoolean is a helper to make a new *Boolean.
39func NewBoolean(v Boolean) *Boolean { return &v }
40
41// NewFloat is a helper to make a new *Float.
42func NewFloat(v Float) *Float { return &v }
43
44// NewID is a helper to make a new *ID.
45func NewID(v ID) *ID { return &v }
46
47// NewInt is a helper to make a new *Int.
48func NewInt(v Int) *Int { return &v }
49
50// NewString is a helper to make a new *String.
51func NewString(v String) *String { return &v }