Using GraphQL with a New Graph Database
What does a graph solution for a GraphQL API look like?
- PDF / 342,656 Bytes
- 13 Pages / 439.37 x 666.142 pts Page_size
- 21 Downloads / 220 Views
Using GraphQL with a New Graph Database esign Goals of the Neo4j-GraphQL D Integration What does a graph solution for a GraphQL API look like? I can best answer this question by looking at the Neo4j-GraphQL plugin. Instead of repeating what Will Lyon says in his video, I have decided to briefly summarize a recent blog post from March 2018, also by Will Lyon of Neo4j. It’s entitled “Five Common GraphQL Problems and How Neo4j-GraphQL Aims To Solve Them1” (see https://blog. grandstack.io/five-common-graphql-problems-and-how-neo4jgraphql-aims-to-solve-them-e9a8999c8d43).
h ttps://blog.grandstack.io/five-common-graphql-problems-and-howneo4j-graphql-aims-to-solve-them-e9a8999c8d43
1
© Thomas Frisendal 2018 T. Frisendal, Visual Design of GraphQL Data, https://doi.org/10.1007/978-1-4842-3904-9_12
93
Chapter 12
Using GraphQL with a New Graph Database
Obviously, there are advantages to using a graph database as a store for a GraphQL API, as you will see. In the following, Will explains the ambitions of the GraphQL Neo4j integration: A few weeks ago, I came across an article from Sacha Greif 2 on freeCodeCamp titled “Five Common Problems in GraphQL Apps (And How to Fix Them)”.3 I thought this was a good overview of some of problems developers encounter when adopting GraphQL. As I read through the list of common problems, I realized these were some of the same issues that users had complained about when we were researching how a Neo4j-GraphQL integration would look4 (see https://neo4j.com/developer/ graphql/). Ultimately, the design of our integration aimed to help developers be more productive when building GraphQL services backed by Neo4j. In this post, I would like to revisit each of the five problems that Sacha points out and show how Neo4j-GraphQL addresses each of those issues.
h ttps://medium.com/@sachagreif https://medium.freecodecamp.org/five-common-problems-in-graphqlapps-and-how-to-fix-them-ac74d37a293c 4 https://neo4j.com/developer/graphql/ 2 3
94
Chapter 12
Using GraphQL with a New Graph Database
Problem 1: Schema Duplication Namely, you need one schema for your database, and another one for your GraphQL endpoint. —Sacha Greif GraphQL uses a strictly defined schema, which defines the types available and the entry points for the API. This schema acts as the specification for the GraphQL API, and with introspection enables powerful developer tools such as query completion, mocking, and documentation generation. However, standard GraphQL implementations often require working with a schema for your database and a schema for your GraphQL API. To simplify the process of building GraphQL applications backed by Neo4j, the Neo4j-GraphQL integration uses the GraphQL schema to infer what the Neo4j data model should be. Solution: Use the GraphQL schema to drive the Neo4j database model.
Problem 2: Server/Client Data Mismatch Your database and GraphQL API will have different schemas, which translate into different document shapes. —Sacha Greif If the backend for your GraphQL service is not a graph databa
Data Loading...