|
1 | 1 | [[index]] |
2 | 2 | = Introduction |
3 | 3 | :page-aliases: introduction.adoc |
4 | | -:description: This section describes the Neo4j GraphQL Library. |
| 4 | +:description: An introduction to the Neo4j GraphQL Library. |
5 | 5 |
|
6 | | -The Neo4j GraphQL Library is a highly flexible, low-code, open source JavaScript library that enables rapid API development for cross-platform and mobile applications by tapping into the power of connected data. |
| 6 | +The Neo4j GraphQL Library is: |
7 | 7 |
|
8 | | -With Neo4j as the graph database, the GraphQL Library makes it simple for applications to have data treated as a graph natively from the frontend all the way to storage. |
9 | | -This avoids duplicate schema work and ensures flawless integration between frontend and backend developers. |
10 | | - |
11 | | -If you are new to Neo4j and GraphQL take a look at xref:getting-started/index.adoc[Creating a new project] and xref:getting-started/toolbox.adoc[Neo4j GraphQL Toolbox] to learn the fundamentals of the Neo4j GraphQL Library and how to create GraphQL APIs backed by a Neo4j graph database. |
| 8 | +* highly flexible and low-code |
| 9 | +* open source |
| 10 | +* a JavaScript library |
| 11 | +* leveraging graph-native data |
12 | 12 |
|
| 13 | +It enables rapid API development for cross-platform and mobile applications. |
13 | 14 |
|
14 | 15 | == How it works |
15 | 16 |
|
16 | | -The Neo4j GraphQL Library requires a set of type definitions that describes the shape of your graph data. |
17 | | -It can generate an entire executable schema with all of the additional types needed to execute queries and mutations to interact with your Neo4j database. |
18 | | - |
19 | | -For every query and mutation that is executed against this generated schema, the Neo4j GraphQL Library generates a single Cypher query which is executed against the database. |
20 | | -This eliminates the https://www.google.com/search?q=graphql+n%2B1[N+1 Problem], which can make GraphQL implementations slow and inefficient. |
21 | | - |
22 | | -The Neo4j GraphQL Library features: |
23 | | - |
24 | | -- Automatic generation of xref::queries-aggregations/queries.adoc[Queries] and xref::mutations/index.adoc[Mutations] for CRUD interactions. |
25 | | -- xref::/types/index.adoc[Types], including temporal and spatial. |
26 | | -- Support for both node and relationship properties. |
27 | | -- Extensibility through the xref::/directives/custom-logic.adoc#_cypher[`@cypher` directive] and/or xref::/directives/custom-logic.adoc#_customresolver[Custom Resolvers]. |
28 | | -- Extensive xref::filtering.adoc[Filtering], xref::queries-aggregations/sorting.adoc[Sorting] and xref::/queries-aggregations/pagination.adoc[Pagination] options. |
29 | | -- Options for xref::/directives/database-mapping.adoc[Database mapping] and value xref::/directives/autogeneration.adoc[Autogeneration]. |
30 | | -- xref::/security/index.adoc[Security options] and additional xref::schema-configuration/index.adoc[Schema Configuration]. |
31 | | -- A xref::getting-started/toolbox.adoc[Toolbox] (UI) to experiment with your Neo4j GraphQL API on Neo4j Desktop. |
32 | | - |
33 | | - |
34 | | -== Interaction |
35 | | - |
36 | | -In xref::getting-started/graphql-aura.adoc[] as well as xref::getting-started/graphql-self-hosted.adoc[], a GraphQL server is used to serve the GraphQL schema, so you can interact directly with your API with no frontend. |
37 | | -In case you prefer to use frontend frameworks, these are some clients that interact with GraphQL APIs: |
38 | | - |
39 | | -- https://reactjs.org/[React] - support through https://www.apollographql.com/docs/react/[Apollo Client] |
40 | | -- https://vuejs.org/[Vue.js] - support through https://apollo.vuejs.org/[Vue Apollo] |
41 | | -- https://angularjs.org/[AngularJS] - support through https://apollo-angular.com/docs/[Apollo Angular]. |
42 | | - |
43 | | - |
44 | | -== Deployment |
45 | | - |
46 | | -There are a variety of methods for deploying GraphQL APIs. |
47 | | - |
48 | | -With Aura Console, you can create and use a GraphQL API, see xref::getting-started/graphql-aura.adoc[]. |
49 | | - |
50 | | -The xref::getting-started/graphql-self-hosted.adoc[] guide uses Apollo Server. |
51 | | -You can check the Apollo documentation on https://www.apollographql.com/docs/apollo-server/deployment[Deployment] for more details. |
52 | | - |
53 | | - |
54 | | -== Versioning |
55 | | - |
56 | | -The Neo4j GraphQL Library uses https://semver.org/[Semantic Versioning]. |
57 | | -Given a version number `MAJOR.MINOR.PATCH`, the increment is based on: |
58 | | - |
59 | | -- `MAJOR` - incompatible API changes compared to the previous `MAJOR` version, for which you will likely have to migrate |
60 | | -- `MINOR` - new features have been added in a backwards compatible manner |
61 | | -- `PATCH` - bug fixes have been added in a backwards compatible manner. |
62 | | - |
63 | | -Additionally, prerelease version numbers may have additional suffixes, for example `MAJOR.MINOR.PATCH-PRERELEASE.NUMBER`, where `PRERELEASE` is one of the following: |
64 | | - |
65 | | -- `alpha` - unstable prerelease artifacts, and the API may change between releases during this phase |
66 | | -- `beta` - feature complete prerelease artifacts, which will be more stable than `alpha` releases but will likely still contain bugs |
67 | | -- `rc` - release candidate including artifacts to be promoted to a stable release, in a last effort to find trailing bugs. |
68 | | - |
69 | | -`NUMBER` in the suffix is simply an incrementing release number in each phase. |
70 | | - |
71 | | - |
72 | | -== Requirements |
73 | | - |
74 | | -. https://neo4j.com/product/auradb/[Neo4j AuraDB] version 2025.x or https://neo4j.com/deployment-center/#gdb-selfmanaged[Neo4j Database] running the latest 5.x version or above with the APOC core plugin. |
| 17 | +The Neo4j GraphQL Library requires a set of type definitions that describes the shape of your graph data and creates an API layer to communicate with the data. |
| 18 | + |
| 19 | +It generates an entire executable schema with all additional types needed to execute queries and mutations to interact with your Neo4j database. |
| 20 | + |
| 21 | +For example, consider these type definitions: |
| 22 | + |
| 23 | +[source, graphql, indent=0] |
| 24 | +---- |
| 25 | +type Product @node { |
| 26 | + productName: String |
| 27 | + category: [Category!]! @relationship(type: "PART_OF", direction: OUT) |
| 28 | +} |
| 29 | +
|
| 30 | +type Category @node { |
| 31 | + categoryName: String |
| 32 | + products: [Product!]! @relationship(type: "PART_OF", direction: IN) |
| 33 | +} |
| 34 | +---- |
| 35 | + |
| 36 | +Based on these type definitions, the library generates query and mutation templates to create new instances of the types as well as query existing instances. |
| 37 | + |
| 38 | +The following mutation creates a new product as well as a new category: |
| 39 | + |
| 40 | +[source, graphql, indent=0] |
| 41 | +---- |
| 42 | +mutation { |
| 43 | + createProducts( |
| 44 | + input: [ |
| 45 | + { |
| 46 | + productName: "New Product" |
| 47 | + category: { create: [{ node: { categoryName: "New Category" } }] } |
| 48 | + } |
| 49 | + ] |
| 50 | + ) { |
| 51 | + products { |
| 52 | + productName |
| 53 | + category { |
| 54 | + categoryName |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | +} |
| 59 | +---- |
| 60 | + |
| 61 | +Here is an example of how you can query existing data: |
| 62 | + |
| 63 | +[source, graphql, indent=0] |
| 64 | +---- |
| 65 | +query { |
| 66 | + products { |
| 67 | + productName |
| 68 | + category { |
| 69 | + categoryName |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | +---- |
| 74 | + |
| 75 | +See xref:using-the-library.adoc[] to learn how to use the GraphQL Library in your technology stack. |
| 76 | +Check out xref:getting-started/index.adoc[] to create a new project, either based on Neo4j Aura or self-hosted. |
75 | 77 |
|
76 | 78 |
|
77 | 79 | == Resources |
|
0 commit comments