Relay
This plugin has extensive integration with the relay plugin, which makes creating nodes and connections very easy.
prismaNode
The prismaNode
method works just like the prismaObject
method with a couple of small
differences:
- there is a new
id
option that mirrors theid
option fromnode
method of the relay plugin, and must contain a resolve function that returns the id from an instance of the node. Rather than defining a resolver for the id field, you can set thefield
option to the name of a unique column or index.
If you need to customize how ids are formatted, you can add a resolver for the id
, and provide a
findUnique
option that can be used to load the node by it's id. This is generally not necessary.
When executing the node(id: ID!)
query with a global ID for which prisma cannot find a record in
the database, the default behavior is to throw an error. There are some scenarios where it is
preferable to return null
instead of throwing an error. For this you can add the nullable: true
option: