forked from graphql-nexus/nexus-prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bytes scalar support (graphql-nexus#75)
- Loading branch information
Showing
12 changed files
with
330 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { GraphQLScalarType } from 'graphql' | ||
import { ByteResolver } from 'graphql-scalars' | ||
import { asNexusMethod } from 'nexus' | ||
|
||
/** | ||
* A Nexus scalar type definition for the `Bytes` scalar type represents byte value as specified by [NodeJS | ||
* Buffer type](https://nodejs.org/api/buffer.html) | ||
* | ||
* Contributes a scalar to your GraphQL schema called `Bytes`. | ||
* | ||
* Contributes a `t` `[1]` helper method called `bytes` | ||
* | ||
* `[1]` A `t` helper method refers to a method on the argument given to a `definition` method. Helper methods | ||
* here typically help you quickly create new fields. | ||
* | ||
* @example | ||
* | ||
* import { makeSchema, objectType } from 'nexus' | ||
* import { Bytes } from 'nexus-prisma/scalars' | ||
* | ||
* SomeObject = objectType({ | ||
* name: 'SomeObject', | ||
* definition(t) { | ||
* t.bytes('someBytesField') | ||
* }, | ||
* }) | ||
* | ||
* makeSchema({ | ||
* types: [Bytes, SomeObject], | ||
* }) | ||
* | ||
*/ | ||
export const Bytes = asNexusMethod( | ||
new GraphQLScalarType({ | ||
...ByteResolver, | ||
// Override the default 'Byte' name with one that matches what Nexus Prisma expects. | ||
name: 'Bytes', | ||
}), | ||
'bytes' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.