Supposing I have a data model that looks something...
# orm-help
w
Supposing I have a data model that looks something like this:
Copy code
id: !ID @unique
name: String!
geodata: String!
and geodata will store stringified json, and then when querying I want the resolver to manipulate that json data somehow, for sake of argument lets say manipulate it into valid geojson, but for reasons I’m not going to go into I don’t need or want an actual geojson field in the database for this data attribute. How might one go about manipulating data in a resolver and similarly in a mutation, as it’s going into/coming out of the data store?
s
Couldn't you just use
JSON.parse
then
JSON.stringify
in your resolver?
e
@willvincent seems like this would be done in the application layer, manipulating the field before/after using the Prisma binding? https://www.prisma.io/docs/tutorials/build-graphql-servers/development/build-a-graphql-server-with-prisma-ohdaiyoo6c#step-6:-implement-the-resolvers-for-your-graphql-server-using-prisma-bindings
s
@willvincent specifically check out the examples/boilerplates that have authentication implemented. They demonstrate how you can bring in an arbitrary function to use within your resolvers.
👍 1
w
I agree it seems like it belongs on the application side. We’re trying to wrap our heads around how things really fit together, and it’s been a rather obtuse uphill fight thus far
👍 1
do you have a specific example I should refer to? The link you gave me doesn’t seem to have the auth related stuff you’re talking about
w
Thanks, yes he did mention, but didn’t link to them 🙂
s
Was driving sorry 😅
w
No worries.. we can’t all work from home. 😉