graphql

bartuka 2019-05-05T01:27:41.036700Z

Hi people, I would like to split the definitions of my schema into several files. Is it possible to do that on lacinia?

lilactown 2019-05-05T03:54:20.037300Z

I think the schema is just EDN, so you can read the files and merge them before you pass it into lacinia

bartuka 2019-05-05T04:29:43.037800Z

Yeah, I just did that. Thanks!

rakowa 2019-05-05T19:21:40.040900Z

Hello there. I'm looking for a pattern that handles UI submission of mutations, and receipt of response data, particularly in reagent.

rakowa 2019-05-05T19:26:09.044600Z

What I have so far are input and submit button components, where input is parsed into the mutation arguments, and the submit button increments a "submissions" ratom. The ratom is dereferenced by the component that issues the mutation. Problem is, when submissions gets swap/inc'ed, entire tree is re-rendered up to where the ratom was instantiated (not, as hoped, only where it gets deref'ed).

lilactown 2019-05-05T19:35:21.044900Z

this sounds like a #reagent question, not a #graphql question

lilactown 2019-05-05T19:36:00.045200Z

it could depend on how you are instantiating / passing around the ratom

rakowa 2019-05-05T19:45:11.048500Z

I think you're right - the ratom question is more for #reagent, but I still wonder if there is a good pattern for UI-driven mutations and result handling.

lilactown 2019-05-05T19:47:46.049500Z

at work, we’ve built a framework using apollo and reagent so that we can push/pull data and represent them as ratoms or promises

2019-05-05T19:50:13.051800Z

Oh apollo? I thought that was hard to incorporate in a cljs codebase

lilactown 2019-05-05T19:50:56.052500Z

typically, a mutation is fired via some action (e.g. a button click). We swap an atom to indicate that the action has fired and notify the user via some UI update. apollo automatically detects that some data in a particular query that components has pulled changed via the mutation, and will then re-query in those components

lilactown 2019-05-05T19:51:04.052600Z

nope, wasn’t too hard at all

lilactown 2019-05-05T19:51:24.052800Z

we don’t use apollo-react, the base apollo-client library is much more amenable to integration with Reagent

2019-05-05T19:51:50.053100Z

ahh that explains. What makes apollo-react hard to intergrate?

2019-05-05T19:52:36.053300Z

(oh, sorry I am hijacking a conversation, I just got interested ^^)

lilactown 2019-05-05T19:52:39.053500Z

using regular react components in Reagent is quite a pain. the patterns that apollo-react uses (HoC and children-as-fn) require lots of converting to- and from- Reagent to React

lilactown 2019-05-05T19:52:48.053700Z

hehe it’s OK 😄

lilactown 2019-05-05T19:52:54.053900Z

with a thinner wrapper around React, apollo-react can be used seamlessly

2019-05-05T19:54:08.054100Z

didn’t you write hx? Would it be easier to integrate with that?

lilactown 2019-05-05T19:54:35.054300Z

I did 🙂 yes, I have an internal app at work I wrote using hx + react-apollo and it was quite seamless

2019-05-05T19:55:02.054500Z

cool! I really like your approach with hx

2019-05-05T19:56:55.054700Z

it feels counterproductive to put layers on top of such a moving target like React 🙂!

lilactown 2019-05-05T20:02:28.055Z

yeah I think there’s some seriously cutting edge things coming out of React this year that we will want to build on top of

lilactown 2019-05-05T20:02:43.055200Z

and unfortunately, libraries like Reagent are not directly compatible with them

rakowa 2019-05-05T20:23:56.056300Z

Ah, so mutation issuance depends on a ratom driven re-render?

lilactown 2019-05-05T20:42:03.056600Z

I don’t think so. I’m not sure I understand the question

lilactown 2019-05-05T20:42:09.056800Z

“issuance”?

lilactown 2019-05-05T20:42:27.057200Z

the mutation is fired when the button is clicked. we swap a ratom to indicate that an action is in progress

lilactown 2019-05-05T20:42:53.057800Z

re-querying for the data is done elsewhere

lilactown 2019-05-05T21:04:55.057900Z

just for giggles, I made an example with react-apollo: https://gist.github.com/Lokeh/bee8fd2010a801354dcbfe7bda371d85

👍 2
rakowa 2019-05-05T22:13:08.058600Z

thanks, that helps!