Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update resolvedData docs for relationships - take 2 #6665

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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