If I have a custom type in my schema that doesn’t ...
# orm-help
c
If I have a custom type in my schema that doesn’t correlate to any data, how do I create a resolver for something not tied to a root resolver? I tried using fragments but that doesn’t seem to be doing anything
d
c
@divyendu Whoa, it might! Thank you, I’ve been stuck on this for awhile
🙌 1
“computed field” was the term I was missing…
👍 1
a
would it be possible to convert a Json field into a type?
d
I assume that you mean JSON in JS resolver and returning a GraphQL type, yes that is possible as long as the fields match. GraphQL spec allows that https://facebook.github.io/graphql/June2018/
a
I mean if I have a field defined as Json like
device_settings: Json
and would like to resolve that field settings to an actual
Settings
type
d
Ah! interesting, it should work in theory, if you are writing the resolver yourself and you pluck out Json value to pass it forward to return.. i.e. as long as the two types are not aware of each other, can you provide a small sample repository where this does not work?
a
absolutely, give me a few min
👍 1
I created a simple project to illustrate it. The datamodel Device has a field
settings:Json
whereas the Device model in the graphql gateway schema defines settings as a union of types. I just don’t know how to convert between the json type and the settings type