You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-6Lines changed: 34 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,10 +18,15 @@ In your schema:
18
18
```graphql
19
19
scalarDateTime
20
20
21
+
scalarNonPositiveInt
21
22
scalarPositiveInt
22
23
scalarNonNegativeInt
24
+
scalarNegativeInt
25
+
26
+
scalarNonPositiveFloat
23
27
scalarPositiveFloat
24
28
scalarNonNegativeFloat
29
+
scalarNegativeFloat
25
30
26
31
scalarEmailAddress
27
32
scalarURL
@@ -31,9 +36,17 @@ In your resolver map, first import them:
31
36
```js
32
37
import {
33
38
DateTime,
39
+
40
+
NonPositiveInt,
34
41
PositiveInt,
42
+
NonNegativeInt,
43
+
NegativeInt,
44
+
45
+
NonPositiveFloat,
35
46
PositiveFloat,
36
47
NonNegativeFloat,
48
+
NegativeFloat,
49
+
37
50
EmailAddress,
38
51
URL,
39
52
} from'@okgrow/graphql-scalars';
@@ -45,10 +58,15 @@ Then make sure they're in the root resolver map like this:
45
58
constmyResolverMap= {
46
59
DateTime,
47
60
61
+
NonPositiveInt,
48
62
PositiveInt,
49
63
NonNegativeInt,
64
+
NegativeInt,
65
+
66
+
NonPositiveFloat,
50
67
PositiveFloat,
51
68
NonNegativeFloat,
69
+
NegativeFloat,
52
70
53
71
EmailAddress,
54
72
URL,
@@ -134,15 +152,27 @@ inevitable parsing or conversion themselves.
134
152
### NonNegativeInt
135
153
Integers that will have a value of 0 or more. Uses [`parseInt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt).
136
154
155
+
### NonPositiveInt
156
+
Integers that will have a value of 0 or less. Uses [`parseInt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt).
157
+
137
158
### PositiveInt
138
159
Integers that will have a value greater than 0. Uses [`parseInt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt).
139
160
161
+
### NegativeInt
162
+
Integers that will have a value less than 0. Uses [`parseInt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt).
163
+
140
164
### NonNegativeFloat
141
165
Floats that will have a value of 0 or more. Uses [`parseFloat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat).
142
166
167
+
### NonPositiveFloat
168
+
Floats that will have a value of 0 or less. Uses [`parseFloat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat).
169
+
143
170
### PositiveFloat
144
171
Floats that will have a value greater than 0. Uses [`parseFloat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat).
145
172
173
+
### NegativeFloat
174
+
Floats that will have a value less than 0. Uses [`parseFloat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat).
175
+
146
176
### EmailAddress
147
177
A field whose value conforms to the standard internet email address format as specified in
148
178
[RFC822](https://www.w3.org/Protocols/rfc822/).
@@ -157,15 +187,11 @@ We'd like to keep growing this package, within reason, to include the scalar typ
157
187
required when defining GraphQL schemas. We welcome both suggestions and pull requests. A couple of
158
188
ideas we're considering are:
159
189
160
-
- NegativeInt
161
-
- NegativeFloat
162
-
163
-
These are easy to add, we just haven't run into cases for them yet.
164
-
165
190
- PhoneNumber
166
191
- PostalCode
192
+
- BLOB
167
193
168
-
These both have challenges in terms of making them globally useful so they need a bit of thought.
194
+
These all have challenges in terms of making them globally useful so they need a bit of thought.
169
195
170
196
For `PhoneNumber` we can probably just use the [E.164 specification](https://en.wikipedia.org/wiki/E.164)
171
197
which is simply `+17895551234`. The very powerful
@@ -176,6 +202,8 @@ parse user input and _get_ the E.164 format to pass _into_ a schema.
176
202
Postal codes are [a bit more involved](https://en.wikipedia.org/wiki/List_of_postal_codes). But,
177
203
again, it's probably just a really long regex.
178
204
205
+
BLOBs could be a base64-encoded object of some kind.
206
+
179
207
## What's this all about?
180
208
GraphQL is a wonderful new approach to application data and API layers that's gaining momentum. If
181
209
you have not heard of it, start [here](http://graphql.org/learn/) and check out
thrownewGraphQLError(`Can only validate floating point numbers as negative floating point numbers but got a: ${ast.kind}`);// eslint-disable-line max-len
thrownewGraphQLError(`Can only validate floating point numbers as non-negative floating point numbers but got a: ${ast.kind}`);// eslint-disable-line max-len
thrownewGraphQLError(`Can only validate floating point numbers as non-positive floating point numbers but got a: ${ast.kind}`);// eslint-disable-line max-len
thrownewGraphQLError(`Can only validate floating point numbers as positive floating point numbers but got a: ${ast.kind}`);// eslint-disable-line max-len
0 commit comments