I want to use graphql to replace an existing API a...
# orm-help
c
I want to use graphql to replace an existing API and I am struggling with how to model the existing response. The API currently returns a list of things that can be of three types: Thing1, Thing2 or AlertThing. There may not be an AlertThing, but if there is, there is only one and it is the first item in the list. Any suggestions how best to model this? Should the schema enforce the list item types (and, if so, how??)? Or should the schema be a a bit more relaxed and simply define the result list as being comprised of the three types and have the resolver enforce the "AlertThing-first-if-any" rule? 🤪
h
I don't think either of those are really possible
your best bet would probably modelling and object from the list
with one optional object and then 2 lists
then resolve it on the server
the original api seems weird to me anyways
c
@harmony re: original api. Agreed!! thanks for your thoughts. 👍