Skip to content

Commit

Permalink
Update resolvedData docs for relationships - take 2 (#6665)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Sep 28, 2021
1 parent a44ae82 commit 97ec32d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/pages/docs/apis/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,12 @@ The data resolving steps are applied in the following order:

1. Initialisation: Set the value of `resolvedData` to the `data` input value from the GraphQL mutation.
2. Defaults (built in, `create` only): Any fields which have a default value and are `undefined` in `resolvedData` will be set to their default value.
3. Relationships (built in): The values for relationship fields on `resolvedData` are either an ID string (for `one` relationships), or an array of ID strings (for `many` relationships).
3. Relationships (built in): The values for relationship fields on `resolvedData` are [Prisma nested write objects](https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries/#connect-an-existing-record).
This is the format expected when saving relationship fields to the database.
The value is computed by combining the provided `connect`, `create`, `disconnect`, and `disconnectAll` values with the existing data in the database.
Any nested create operations are performed as part of this process.
Any nested create operations are performed during this phase. Their IDs are returned, and combined with any `connect` inputs.
All items provided for `connect`, `set`, and `disconnect` are checked to ensure they exist.
For to-many relationships, an object with the shape `{ connect: [...], set: [...], disconnect: [...] }` is returned.
For to-one relationships, an object with the shape `{ connect }` or `{ disconnect: true }` is returned.
4. Field values (built in): Some fields types take the value given in the GraphQL operation and convert it into a different type or format to be saved to the database.
5. Field hooks (user defined): A `resolveInput` field hook can return a new value for its field, which will the current field value on `resolvedData`.
6. List hooks (user defined): A `resolveInput` list hook can return a new value for the entire `resolvedData` object.
Expand Down

1 comment on commit 97ec32d

@vercel
Copy link

@vercel vercel bot commented on 97ec32d Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.