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
* feat(objectid-scalar): mongodb object id scalar type
Adds mongodb object id scalar type.
* style(editorconfig): editorconfig to help format code
Adds [editorconfig](https://editorconfig.org/) to helps maintain coding style for developers.
* style(commitlint): git commit message linting
Enforces commit message standards on subsequent contributors to this project.
* docs(mongodb-objectid): documents the usage of the mongodb objectid
Documents the usage of the mongodb objectid scalar type.
* feat(mongodb-objectid): mongodb objectid scalar type
Adds mongodb objectid scalar type
* feat(mongodb-objectid): mongodb objectid scalar type
Adds a mongodb objectid scalar type definition to the already existing list of definitions.
* conflict resolution (#1)
package.json rebased
* feat(objectid-scalar): mongodb object id scalar type
Adds mongodb object id scalar type.
* docs(mongodb-objectid): documents the usage of the mongodb objectid
Documents the usage of the mongodb objectid scalar type.
* git rebase (#2)
conflict resolution -package.json
* feat(objectid-scalar): mongodb object id scalar type
Adds mongodb object id scalar type.
* style(editorconfig): editorconfig to help format code
Adds [editorconfig](https://editorconfig.org/) to helps maintain coding style for developers.
* style(commitlint): git commit message linting
Enforces commit message standards on subsequent contributors to this project.
* docs(mongodb-objectid): documents the usage of the mongodb objectid
Documents the usage of the mongodb objectid scalar type.
* feat(mongodb-objectid): mongodb objectid scalar type
Adds a mongodb objectid scalar type definition to the already existing list of definitions.
* build: remove package-lock.json
Please read OK Grow's global [contribution guidelines](https://github.com/okgrow/guides/blob/master/open-source/contributing.md).
4
+
5
+
If you are interested in becoming a maintainer, get in touch with us by sending an email or opening an issue. You should already have code merged into the project. Active contributors are encouraged to get in touch.
6
+
7
+
Please note that all interactions in @okgrow's repos should follow our [Code of Conduct](https://github.com/okgrow/guides/blob/master/open-source/CODE_OF_CONDUCT.md).
8
+
9
+
All commit messages should follow the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) message guidelines. In order to assist with this you can run `npm run-scripts commit` as a command has been added to the scripts section of the `package.json` file which will help guide formulation of a proper commit message.
Copy file name to clipboardExpand all lines: README.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,8 @@ scalar UnsignedInt
58
58
59
59
scalarURL
60
60
61
+
scalarObjectID
62
+
61
63
scalarBigInt
62
64
63
65
scalarLong
@@ -126,13 +128,16 @@ import {
126
128
USCurrencyResolver,
127
129
JSONResolver,
128
130
JSONObjectResolver,
131
+
ObjectIDResolver,
129
132
} from'graphql-scalars';
130
133
```
131
134
132
135
Then make sure they're in the root resolver map like this:
133
136
134
137
```javascript
135
138
constmyResolverMap= {
139
+
ObjectID: ObjectIDResolver,
140
+
136
141
DateTime: DateTimeResolver,
137
142
138
143
NonPositiveInt: NonPositiveIntResolver,
@@ -147,27 +152,27 @@ const myResolverMap = {
147
152
UnsignedInt: UnsignedIntResolver,
148
153
BigInt: BigIntResolver,
149
154
Long: LongResolver,
150
-
155
+
151
156
EmailAddress: EmailAddressResolver,
152
157
URL: URLResolver,
153
158
PhoneNumber: PhoneNumberResolver,
154
159
PostalCode: PostalCodeResolver,
155
-
160
+
156
161
GUID: GUIDResolver,
157
-
162
+
158
163
HexColorCode: HexColorCodeResolver,
159
164
HSL: HSLResolver,
160
165
HSLA: HSLAResolver,
161
166
RGB: RGBResolver,
162
167
RGBA: RGBAResolver,
163
-
168
+
164
169
IPv4: IPv4Resolver,
165
170
IPv6: IPv6Resolver,
166
171
MAC: MACResolver,
167
172
Port: PortResolver,
168
-
173
+
169
174
ISBN: ISBNResolver,
170
-
175
+
171
176
USCurrency: USCurrencyResolver,
172
177
JSON: JSONResolver,
173
178
JSONObject: JSONObjectResolver,
@@ -482,6 +487,10 @@ The very powerful
482
487
_that_ format, parse and display it in whatever display format you want. It can also be used to
483
488
parse user input and _get_ the E.164 format to pass _into_ a schema.
484
489
490
+
### ObjectID
491
+
492
+
A field whose value conforms to the mongodb object id format as explained in the [documentation](https://docs.mongodb.com/manual/reference/method/ObjectId/#ObjectId)
493
+
485
494
### PostalCode
486
495
487
496
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/)
@@ -509,7 +518,7 @@ In the future we might expand this list and use the more comprehensive list foun
509
518
510
519
### BigInt
511
520
512
-
A long integer type for [graphql-js](https://github.com/graphql/graphql-js). This implementation gives you more than 32 bits rather than the default 32-bit GraphQLInt. [It uses native `BigInt` implementation of JavaScript.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
521
+
A long integer type for [graphql-js](https://github.com/graphql/graphql-js). This implementation gives you more than 32 bits rather than the default 32-bit GraphQLInt. [It uses native `BigInt` implementation of JavaScript.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
513
522
The [GraphQL spec](https://facebook.github.io/graphql/#sec-Int) limits its Int type to 32-bits. Maybe you've seen this error before:
514
523
[Issue on graphql-js](https://github.com/graphql/graphql-js/issues/292)
515
524
```
@@ -704,13 +713,13 @@ can use them too if needed.
704
713
705
714
## License
706
715
707
-
Released under the [MIT license](https://github.com/Urigo/graphql-scalars/blob/master/LICENSE).
'A field whose value conforms with the standard mongodb object ID as described here: https://docs.mongodb.com/manual/reference/method/ObjectId/#ObjectId. Example: 5e5677d71bdc2ae76344968c',
11
+
12
+
serialize(value: string){
13
+
if(!MONGODB_OBJECTID_REGEX.test(value)){
14
+
thrownewTypeError(`Value is not a valid mongodb object id of form: ${value}`);
15
+
}
16
+
17
+
returnvalue;
18
+
},
19
+
20
+
parseValue(value: string){
21
+
if(!MONGODB_OBJECTID_REGEX.test(value)){
22
+
thrownewTypeError(`Value is not a valid mongodb object id of form: ${value}`);
23
+
}
24
+
25
+
returnvalue;
26
+
},
27
+
28
+
parseLiteral(ast: ValueNode){
29
+
if(ast.kind!==Kind.STRING){
30
+
thrownewGraphQLError(
31
+
`Can only validate strings as mongodb object id but got a: ${ast.kind}`,
32
+
);
33
+
}
34
+
35
+
if(!MONGODB_OBJECTID_REGEX.test(ast.value)){
36
+
thrownewTypeError(`Value is not a valid mongodb object id of form: ${ast.value}`);
0 commit comments