-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add @appendNode and @prependNode directives for updating the store #3155
Conversation
…dges+nodes to connections without requiring the server to return a real edge
packages/relay-compiler/transforms/DeclarativeConnectionMutationTransform.js
Outdated
Show resolved
Hide resolved
…d-node-directive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Does it work if the edgeType is a constant in the directive?
…d-node-directive
…tead of variable to edgeTypeName
@tyao1 Thanks for having a look. Yes it does. I added a test to show it, please see the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for the extra tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyao1 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
ERROR: |
Would be great if these directives could be documented! |
How do this variant?
index.js:1 Warning: MutationHandlers: Expected target node to exist. |
Hey @anatooly , I found if I use directives on a field with arguments they will not work. Please retry with a field without agrument, I believe there is a bug in implement of those directives |
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: