Fork me on GitHub
#graphql
<
2020-06-16
>
steveb8n01:06:29

Q: I want to use the data inside ::lacinia/selection in my resolvers. Is this considered a stable public api/data?

hlship16:06:27

It is not. Use it are your peril. However, there's the selections API that exposes the most useful information in there.

steveb8n23:06:15

I’m glad I asked 🙂. What I’m trying to see is the field “type” for non-leaf resolvers. I can infer if from the keyword namespaces in the data from the selections api but that seems a bit indirect. Is there a better way?

steveb8n00:06:11

since I always have an “id” field in my queries, here’s what seems to work using the selection api

steveb8n00:06:14

(some->> (executor/selections-tree context)
         (select-first [MAP-KEYS #(= "id" (name %))])
         namespace
         keyword)

steveb8n00:06:48

that’s specter in the second step so not material to this question

steveb8n00:06:17

just wondering if there’s a more direct way to do this but I’m happy to move forward with this solution

hlship16:06:44

The conflict here is that we really don't want to lock down the structure of the many internal keys in the context, as that handcuffs against any future changes and improvements.

hlship16:06:53

But at the same time, there's often a need for data we don't expose.

hlship16:06:22

So we've been gradually extending the preview API, which is something we can test and maintain, even in the face of a reorganization of the data in the context.

hlship16:06:50

At this point, we can add more data to the maps returned by https://walmartlabs.github.io/apidocs/lacinia/com.walmartlabs.lacinia.executor.html#var-selections-seq2 without breaking any clients, so that's who I'd prefer to go.

hlship16:06:35

Returning more field type data, as well as field and argument directives, would address a lot of needs, AFAIK.

steveb8n00:06:20

yes, that would pretty much be what I need. that said, I can use config/factories for now to achieve the same result. since I generate my schemas, this is not a big deal.

steveb8n00:06:41

touch base if you decide to add more data. I can chime in with that would help me

steveb8n00:06:48

thanks for the feedback