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
+45-16Lines changed: 45 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,9 @@ scalar NegativeFloat
30
30
31
31
scalarEmailAddress
32
32
scalarURL
33
+
34
+
scalarPhoneNumber
35
+
scalarPostalCode
33
36
```
34
37
35
38
In your resolver map, first import them:
@@ -49,6 +52,9 @@ import {
49
52
50
53
EmailAddress,
51
54
URL,
55
+
56
+
PhoneNumber,
57
+
PostalCode,
52
58
} from'@okgrow/graphql-scalars';
53
59
```
54
60
@@ -71,6 +77,9 @@ const myResolverMap = {
71
77
EmailAddress,
72
78
URL,
73
79
80
+
PhoneNumber,
81
+
PostalCode,
82
+
74
83
Query: {
75
84
// more stuff here
76
85
},
@@ -117,6 +126,9 @@ type Person {
117
126
118
127
email: EmailAddress
119
128
homePage: URL
129
+
130
+
phoneNumber: PhoneNumber
131
+
homePostalCode: PostalCode
120
132
}
121
133
122
134
```
@@ -181,28 +193,45 @@ A field whose value conforms to the standard internet email address format as sp
181
193
A field whose value conforms to the standard URL format as specified in
182
194
[RFC3986](https://www.ietf.org/rfc/rfc3986.txt).
183
195
196
+
### PhoneNumber
197
+
A field whose value conforms to the standard E.164 format as specified in
198
+
[E.164 specification](https://en.wikipedia.org/wiki/E.164). Basically this is `+17895551234`.
199
+
The very powerful
200
+
[`libphonenumber` library](https://github.com/googlei18n/libphonenumber) is available to take
201
+
_that_ format, parse and display it in whatever display format you want. It can also be used to
202
+
parse user input and _get_ the E.164 format to pass _into_ a schema.
184
203
185
-
## Future
186
-
We'd like to keep growing this package, within reason, to include the scalar types that are widely
187
-
required when defining GraphQL schemas. We welcome both suggestions and pull requests. A couple of
188
-
ideas we're considering are:
204
+
### PostalCode
205
+
We're going to start with a limited set as suggested [here] (http://www.pixelenvision.com/1708/zip-postal-code-validation-regex-php-code-for-12-countries/)
206
+
and [here] (https://stackoverflow.com/questions/578406/what-is-the-ultimate-postal-code-and-zip-regex).
189
207
190
-
- PhoneNumber
191
-
- PostalCode
192
-
- BLOB
208
+
Which gives us the following countries:
193
209
194
-
These all have challenges in terms of making them globally useful so they need a bit of thought.
210
+
- US - United States
211
+
- UK - United Kingdom
212
+
- DE - Germany
213
+
- CA - Canada
214
+
- FR - France
215
+
- IT - Italy
216
+
- AU - Australia
217
+
- NL - Netherlands
218
+
- ES - Spain
219
+
- DK - Denmark
220
+
- SE - Sweden
221
+
- BE - Belgium
222
+
- IN - India
195
223
196
-
For `PhoneNumber` we can probably just use the [E.164 specification](https://en.wikipedia.org/wiki/E.164)
197
-
which is simply `+17895551234`. The very powerful
198
-
[`libphonenumber` library](https://github.com/googlei18n/libphonenumber) is available to take
199
-
_that_ format, parse and display it in whatever display format you want. It can also be used to
200
-
parse user input and _get_ the E.164 format to pass _into_ a schema.
224
+
This is really a practical decision of weight (of the package) vs. completeness.
201
225
202
-
Postal codes are [a bit more involved](https://en.wikipedia.org/wiki/List_of_postal_codes). But,
203
-
again, it's probably just a really long regex.
226
+
In the future we might expand this list and use the more comprehensive list found [here] (http://unicode.org/cldr/trac/browser/tags/release-26-0-1/common/supplemental/postalCodeData.xml).
227
+
228
+
229
+
## Future
230
+
We'd like to keep growing this package, within reason, to include the scalar types that are widely
231
+
required when defining GraphQL schemas. We welcome both suggestions and pull requests. One idea
232
+
we're considering is:
204
233
205
-
BLOBs could be a base64-encoded object of some kind.
234
+
- BLOB, could be could be a base64-encoded object of some kind
206
235
207
236
## What's this all about?
208
237
GraphQL is a wonderful new approach to application data and API layers that's gaining momentum. If
0 commit comments