Based on the basic grandstack app I am trying to load data from neo4j and visualize them based on the forcegraph 2d package. However, I am not capable of retrieving the data in the structure so that I can put them in the forcegraph.
As a test query in schema.graphql I use:
networkData: [networkDat] @cypher(statement: """ MATCH (n)-->(m) WITH id(n) AS source, id(m) AS target RETURN {source:source, target:target} as rob LIMIT 5 """)
and in my react component: const GET_NETWORK_QUERY = gql` { networkData (first:2){ source target } }
then I do: const { data } = useQuery(GET_NETWORK_QUERY)
if I log this in it gives me:
{networkData: [{source: 2, target: 1, __typename: "networkDat"}, {source: 1274, target: 3, __typename: "networkDat"}]}
I guess the crucial point is to restructure the data in the correct way, so what I need is: {nodes: [{name: "A"}, {name: "B"}], links: [{source: "A", target: "B"}]}
Thanks for any advice!
What does your query look like in GraphQL? How is your schema set up? You're more than likely going to have to make the request and spend some time figuring out how to restructure the data received from your query to match what forcegraph is expecting.