mattkrick / cashay

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

Will your library work with postgraphql? #79

Closed meglio closed 8 years ago

meglio commented 8 years ago

This is not an issue, but rather just a question.

If I understand correctly, cashay is a client library to query a GraphQL server. The question is, should it work seamlessly with postgraphql?

mattkrick commented 8 years ago

Probably. Correct me if i'm wrong, but postgraphql just takes a sql schema & converts it into a graphql schema. If that's correct, then it's fine since Cashay takes in a graphql schema & outputs a client schema.

If it doesn't work, let me know what's breaking & we can fix it up.

meglio commented 8 years ago

Yes, all correct, postgraphql is just a js server that generates a GraphQL schema automatically based on a PostgreSQL instance.

Thanks for answering quickly. Not quite yet prototyping the application, just reading about existing js GraphQL clients and designing the application.

Cashay documentation says this:

Cashay uses a client-safe portion of your GraphQL schema, similar to GraphiQL, but way smaller.

... I'm trying to figure out what limitations will it put to me using Cashay as a GraphQL consumer. The comparison table shows where Cashay is better than Relay, but not when it is worse.

mattkrick commented 8 years ago

If you want query aggregation or you don't want to send a schema to the client, you'll need relay. I'd encourage you to get familiar with both though. Relay has a fantastic support community and the financial backing of facebook, but it seems really, really clunky to me.

Writing a product that competes with facebook's stuff wasn't a decision I made lightly. If you read my medium article on cashay (link to my medium page is in my github profile) it'll go into more detail as to why I designed it as I did & why it's superior for my use case. Primarily: I hate writing 100 LOC mutations, I like using redux (persisting data is SO easy!), and I need support for subscriptions.

meglio commented 8 years ago

Re query aggregation: a db view can be used instead with a normal querying from Cashay, do you think it should work? p.s. yep, I had read your Medium post before writing ;) That's why I'm here though.

mattkrick commented 8 years ago

I'm not sure I understand your question. Relay has you write fragments & then the containers crawl through the child components picking up those fragments. If the child is nondeterministic, it will queue up that request & execute it when the first query comes back.

Cashay has you write entire GraphQL queries instead of just fragments. That means you'll either need to colocate your queries with the component that needs it, or in your parent component you'll need to request information that child components need.

A good (advanced) example is in the cashay playground, how all Posts are loaded in 1 query, and then each group of comments is loaded in its own separate query.