-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
Hey. When I write my code I'm designing it not coding thus I have lots of questions :). Btw, I like your code style. How would you handle nested resources like /projects/:project_id/products/:id. All tutorials (not just yours) have mutations defined on the root mutation (no nesting). As I described here graphql/graphql-js#221 we could have nested resources the same way as we would do it in REST (nested query). I wonder if that logic is acceptable in graphql. I would like to see how others handle this case.
Example:
// PUT /projects/:project_id/products/:id
mutation {
// example 1
findProject(id: 1) { // make sure that the project exists and we can access it before mutating data
updateProduct(id: 1, name: "Foo") { // the resolve function receives a valid `project` as the first arg
id
}
}
// example 2
updateProjectProduct(projectId: 10, name: "Product 1") {id}
// example 3
updateProjectProduct(projectId: 10, product: { name: "Product 1"}) {id}
}Also, should the update or delete mutation return an object or null or {status: 'ok'} or else?
Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels