mattkrick / cashay

:moneybag: Relay for the rest of us :moneybag:
MIT License
453 stars 28 forks source link

mutation must have sub-fields #141

Closed dustinfarris closed 7 years ago

dustinfarris commented 7 years ago

Got this error doing a simple:

cashay.mutate('createProject', { variables: { name } });

screenshot

I think it is probably because I don't have any mutation handlers set up yet. If that is the case perhaps this error could be trapped and rewritten.

mattkrick commented 7 years ago

Right you are! This is a point of frustration for me with GraphQL. If the mutation is supposed to return type X, you need to request type X from it. Right now, cashay does that for you by looking at your mutation handlers and writing the mutation for you. Even though this is great, prevents under/over fetching, human error etc, it does feel unnatural for some requests. I'm thinking about rewriting the mutations API so the mutation handlers are on the mutation itself and the fetched fields are user defined. That could result in a little more over fetching, but removes the magic. If you have any thoughts I'd love to hear em!

On Dec 1, 2016 10:41 AM, "Dustin Farris" notifications@github.com wrote:

Got this error doing a simple:

cashay.mutate('createProject', { variables: { name } });

[image: screenshot] https://camo.githubusercontent.com/0505a3825710f3d09dd3fce07ba3d619f03f4d4c/68747470733a2f2f7777772e64726f70626f782e636f6d2f732f75706f64327361343566366d3278322f53637265656e73686f74253230323031362d31322d303125323031332e33392e32312e706e673f646c3d31

I think it is probably because I don't have any mutation handlers set up yet. If that is the case perhaps this error could be trapped and rewritten.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mattkrick/cashay/issues/141, or mute the thread https://github.com/notifications/unsubscribe-auth/AFQjv0FRQ62XQvlIYYRJtVXCjgk_EOL8ks5rDxTJgaJpZM4LBvmO .

dustinfarris commented 7 years ago

It feels like having mutation-related stuff isolated to the mutation call would make more sense. But as a newcomer, I am just scratching the surface in terms of applicability—so it's hard to weight pros/cons. I am starting to understand the benefit of the intersection of related queried fields. It would be a lot of fields to keep track of as the app grows I imagine.

But for your reference, my first thought was, "I want to do a mutation. Why do I have to mess with my queries?"

On Dec 1, 2016, at 3:08 PM, Matt Krick notifications@github.com wrote:

Right you are! This is a point of frustration for me with GraphQL. If the mutation is supposed to return type X, you need to request type X from it. Right now, cashay does that for you by looking at your mutation handlers and writing the mutation for you. Even though this is great, prevents under/over fetching, human error etc, it does feel unnatural for some requests. I'm thinking about rewriting the mutations API so the mutation handlers are on the mutation itself and the fetched fields are user defined. That could result in a little more over fetching, but removes the magic. If you have any thoughts I'd love to hear em!

On Dec 1, 2016 10:41 AM, "Dustin Farris" notifications@github.com wrote:

Got this error doing a simple:

cashay.mutate('createProject', { variables: { name } });

[image: screenshot] https://camo.githubusercontent.com/0505a3825710f3d09dd3fce07ba3d619f03f4d4c/68747470733a2f2f7777772e64726f70626f782e636f6d2f732f75706f64327361343566366d3278322f53637265656e73686f74253230323031362d31322d303125323031332e33392e32312e706e673f646c3d31

I think it is probably because I don't have any mutation handlers set up yet. If that is the case perhaps this error could be trapped and rewritten.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mattkrick/cashay/issues/141, or mute the thread https://github.com/notifications/unsubscribe-auth/AFQjv0FRQ62XQvlIYYRJtVXCjgk_EOL8ks5rDxTJgaJpZM4LBvmO .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mattkrick/cashay/issues/141#issuecomment-264280099, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCWvaRg-3ZWhQwZzGKRGwzsv2-C7A1Oks5rDykkgaJpZM4LBvmO.

-- Dustin Farris

mattkrick commented 7 years ago

agreed, it's a many-to-many relationship (one mutation affects many queries, one query is affected by many mutations). there isn't a clean way to do it, but there is definitely room for improvement.