cancel
Showing results for 
Search instead for 
Did you mean: 

How to best retrieve JSON string as a property on a node

julian_deflandr
Node Link

I am attempting to store comments in a GRANDstack application. I currently store the comment like this:

type Comment {
id: ID!
author: ID!
delta: String
}

Where delta is a quilljs delta object that I have stringified and looks like this:

{"ops":[{"insert":"Test comment\n"}]}

What would be the best way to turn this back into an object when I query for a comment in my graphql schema?

Do I need some kind of apoc function on the Comment type for the delta property? The only solution I can think of right now is to JSON.parse(delta) on the client side, but this would be rather convoluted and inefficient for me. Thanks for any help or suggestions!

1 ACCEPTED SOLUTION

MuddyBootsCode
Graph Steward

I believe you can actually store it as a JSON object and use that type and declar a

scalar JSON

type that you can use. You could also store it as a map or something of that nature.

View solution in original post

4 REPLIES 4

MuddyBootsCode
Graph Steward

I believe you can actually store it as a JSON object and use that type and declar a

scalar JSON

type that you can use. You could also store it as a map or something of that nature.

Forgive me, I'm new to using Neo4j and GraphQL. Could you help me understand how to declare a scalar JSON type in my GraphQL schema file?

Just like above. You would put that in your schema and then you can use it like Dog: JSON, etc.

jggomez
Graph Voyager

Hi, you can save as JSON String so you convert this in your app

Ok.