-
Notifications
You must be signed in to change notification settings - Fork 212
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
Mutations Support #406
Mutations Support #406
Conversation
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.
This is looking great! Please make sure to format all files with Prettier. 😄
src/validation/schema.js
Outdated
`ObjectTypeDefinition '${def.name.value}' found, Mutation ` + | ||
"must be the only type. Try using 'input' for mutation arguments, " + | ||
"'interface' for mutation return values, or existing @entity types from the subgraph schema.", |
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.
Let's unravel this a little bit. How about this error mesage?
`\
Encountered object type '${def.name.value}. 'Mutation' is the only \
object type allowed in the mutations schema.
For mutation arguments, use 'input' types. For return values, use either \
entity types from the subgraph schema or interfaces.`
I actually think that we should allow other, non-entity types as return values here, and should allow users to define these types in the mutations schema.
The combined schema validation would have to become a little smarter to handle these. One trick could be to transform the type definitions in the mutations schema to add a @mutations
directive to all of them. In the combined schema validation, we could then ignore all types with this 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.
Re @mutations directive: This would require changes within the graph-node to ignore these new types correct?
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.
The error message has been updated with the version you wrote, thank you for simplifying the wording!
@@ -9,6 +9,206 @@ describe('Validation', () => { | |||
exitCode: 1, | |||
}, | |||
) | |||
cliTest( |
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.
I'm going to skip reviewing the tests for now, because they may change a little after the code review has been addressed. I'm glad to see so many tests though!
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.
Tests have been updated.
One more comment: We have an (undocumented) convention for our commit messages. The commit subject is expected to start with the "module" or scope that the changes are made against. Would it be possible to follow this convention in this PR as well? Check some of the more recent commit messages for reference:
|
@Jannis in order to follow the commit message standard, I can recreate this PR from a new branch where I commit the file changes one by one. Does that sound like a good choice to you? |
@dOrgJelli Why not rebase and reword all commit messages as you go? |
f07fa29
to
717cccd
Compare
@Jannis commit messages have been updated |
Closing as stale, but definitely interested in reigniting mutation discussions! |
With these changes the
graph build
command now supports subgraph mutations.Here's an example project setup:
subgraph.yaml
mutations.yaml
src/mutations/schema.graphql
schema.graphql
The following syntax is also supported:
subgraph.yaml