Skip to content

Commit fddb5bf

Browse files
committed
doc(Scalar) improve scalar description
1 parent 0739c11 commit fddb5bf

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/graphql/scalar_type.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
module GraphQL
2-
# The parent type for scalars, eg {GraphQL::STRING_TYPE}, {GraphQL::INT_TYPE}
2+
# # GraphQL::ScalarType
3+
#
4+
# Scalars are plain values. They are leaf nodes in a GraphQL query tree.
5+
#
6+
# ## Built-in Scalars
7+
#
8+
# `GraphQL` comes with standard built-in scalars:
9+
#
10+
# Constant | `.define` helper
11+
# =========|==================
12+
# `GraphQL::STRING_TYPE` | `types.String`
13+
# `GraphQL::INT_TYPE` | `types.Int`
14+
# `GraphQL::FLOAT_TYPE` | `types.Float`
15+
# `GraphQL::ID_TYPE` | `types.ID`
16+
# `GraphQL::BOOLEAN_TYPE` | `types.Boolean`
17+
#
18+
# (`types` is an instance of `GraphQL::Definition::TypeDefiner`; `.String`, `.Float`, etc are methods which return built-in scalars.)
19+
#
20+
# ## Custom Scalars
21+
#
22+
# You can define custom scalars for your GraphQL server. It requires some special functions:
23+
#
24+
# - `coerce_input` is used to prepare incoming values for GraphQL execution. (Incoming values come from variables or literal values in the query string.)
25+
# - `coerce_result` is used to turn Ruby values _back_ into serializable values for query responses.
326
#
427
# @example defining a type for Time
528
# TimeType = GraphQL::ScalarType.define do

0 commit comments

Comments
 (0)