Timo
07/17/2018, 8:03 PMresolvers/Query.js
, resolvers/Mutation.js
)... can I divide them into let's say User/Query.js
and User/Mutation.js
and other models following the same design?agartha
07/17/2018, 8:14 PMArnab
07/18/2018, 12:02 PMresolvers
folder with queries
and mutations
as subfolders is also useful.
Alternatively, you can have queries and mutations grouped together by the types. As in my_app/src/users/queries.js
, my_app/src/users/mutations.js
Arnab
07/18/2018, 12:03 PMErrorname
07/18/2018, 5:02 PMresolvers
folder with a few files (user.js, stuff.js, ...). In each of these file, I do the following:
export {
Query: {
myQuery1: ...
},
Mutation: {
myMutation1: ...
}
}
Which is better to group the logic I thinkArnab
07/18/2018, 5:17 PMuser
to an object (say post
or comment
)?Errorname
07/18/2018, 5:18 PMErrorname
07/18/2018, 5:20 PMArnab
07/18/2018, 5:20 PMArnab
07/18/2018, 5:20 PMposts.js
or user.js
?Errorname
07/18/2018, 5:24 PMcreateComment
mutation. But if you specifically want a mutation which only connect the two, I would probably put it in comments.js as User is kind of a "super-object" (used nearly everywhere).
Let's imagine you wanted to completely remove the comment feature of your app: You would only need to delete the comments.js
file!Errorname
07/18/2018, 5:25 PMArnab
07/18/2018, 5:26 PMTimo
07/19/2018, 3:39 PMresolvers/Customer/Customer.js
as the class, then resolvers/Customer/Mutation.js
as the mutation and resolvers/Customer/Query,js
as the queries... so per model per directory