-3

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!

Tobias
  • 1
  • 1
  • Can you share some code – Tomaž Bratanič Sep 03 '20 at 15:59
  • Thanks for formatting that. Is this on an object of Type Publication? Do you have referential relationships set up between pubCitations and Publications? What does the rest of your schema look like? Do you have a gist or something to share? – Michael Porter Sep 12 '20 at 12:42
  • Sorry, I copied the wrong query. You can find the correct now now in the original post, hope it's clearer now. Thanks. – Tobias Sep 13 '20 at 09:17

1 Answers1

0

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.

Michael Porter
  • 229
  • 3
  • 12