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
Add @appendNode and @prependNode directives for updating the store (#3155)
Summary:
This adds two new directives, `appendNode` and `prependNode`, for updating the store declaratively. The directives will create an edge for the annotated object and prepend/append that edge to the provided connections. It works with single nodes as well as lists of nodes.
Example:
```
mutation AddComments(
$input: AddCommentsInput!,
$connections: [String!]!,
$edgeTypeName: String!
) {
addComments(input: $input) {
# It works for lists of nodes as well as for single nodes
comments appendNode(connections: $connections, edgeTypeName: $edgeTypeName) {
id
}
# This mutation naturally doesn't make sense, but is just here to illustrate that this works for a single node as well
comment appendNode(connections: $connections, edgeTypeName: $edgeTypeName) {
id
}
}
}
```
Pull Request resolved: #3155
Reviewed By: kassens
Differential Revision: D23390489
Pulled By: tyao1
fbshipit-source-id: 31d23d455651c0b05d46b2ac8b7edb5665b88265
Copy file name to clipboardexpand all lines: packages/relay-compiler/transforms/__tests__/__snapshots__/DeclarativeConnectionMutationTransform-test.js.snap
Copy file name to clipboardexpand all lines: packages/relay-runtime/store/__tests__/RelayModernEnvironment-ExecuteMutationWithDeclarativeMutation-test.js
0 commit comments