Fork me on GitHub
#graphql
<
2020-09-22
>
λustin f(n)01:09:36

I am trying to merge together two representations of a user from different sources. Is there a guide or best practices I should use for this? Is it mostly a matter of having the resolver for the type 'know' the different sources the data comes from, and be built to determine which source to pull from to provide the proper fields?

hiredman17:09:43

not sure how helpful this is, but I would approach it as some kind of sql join(as a mental model, even if the underlying datasources aren't sql)

hiredman17:09:52

and then the semantics of whatever kind of join you use tell you what the results should be

Lennart Buit20:09:53

I guess I would do ik like you describe, have a resolver high up that knows about both sources, and combine a value that field resolvers ‘deeper’ can use to resolve. There is an api to preview selections, so your all knowing ‘high’ field resolver can know which datasources it needs to query, say because its expensive

Lennart Buit20:09:29

The alternative, if the type is really split between services (for whatever reason) is Federation, but thats a pretty hard handed solution for a scaling / scattered data problem I don’t think you describe to have :)

Lennart Buit20:09:30

(Its also a bit controversial, maybe?)

hlship18:09:06

I’m finding a lot of bugs related to directives as I’m working on exposing a solid (protocol-based) API to get at them.

jacklombard20:09:18

I get this error when adding lacinia to my project

clojure.lang.ExceptionInfo: Conflicting data-reader mapping {:url #object[java.net.URL 0x792b749c "jar:file:/Users/sunil.ks/work/qt/sketches/.m2/ordered/ordered/1.3.2/ordered-1.3.2.jar!/data_readers.clj"], :conflict ordered/set, :mappings {ordered/set #'flatland.ordered.set/into-ordered-set, ordered/map #'flatland.ordered.map/ordered-map, dbg #'cider.nrepl.middleware.debug/debug-reader, break #'cider.nrepl.middleware.debug/breakpoint-reader, light #'cider.nrepl.middleware.enlighten/light-reader}}
It is because of org.flatland/ordered and I’m not sure how to resolve this.

jacklombard04:09:54

I don’t have anyother library that uses this flatland library, sort of stuck at this.

orestis06:09:22

Which is a super old version, and under a different package

jacklombard07:09:54

Sorry I didn’t quite get you. The above library isn’t listed in my lein deps :tree

orestis08:09:26

I’m not familiar with lein, perhaps there’s some user-level profile that adds the dependency to all your projects?

orestis08:09:36

But it’s clear that there’s #ordered/set from ordered/ordered that conflicts with #ordered/set from flatland.ordered.set

jacklombard08:09:24

Great that worked! I excluded ordered from a library called print.foo

jacklombard08:09:51

How did you find out that it was ordered that was causing the conflict?

orestis09:09:38

It’s right there in the error message :)

orestis09:09:08

.m2/ordered/ordered/1.3.2

jacklombard09:09:24

Oh damn 🙂 Thanks a lot!

jacklombard20:09:21

lacinia version is the latest “0.38.0-alpha-2”

Lennart Buit21:09:21

I believe lacinia has a vendorized version of that lib, so you have the same clj file twice on your classpath (because you also depend on org.flatland/ordered )

Lennart Buit21:09:31

Maybe you’ll have some luck excluding the other instance of org.flatland/ordered

hlship21:09:50

No, we don’t have that library vendored anymore. That was temporary while the lib was in a bad state.

👍 3
hlship21:09:16

We use org.flatland/ordered “1.5.9”