{"id":15678130,"url":"https://github.com/meistermeier/spring-graphql-neo4j","last_synced_at":"2025-05-07T02:23:40.237Z","repository":{"id":139658052,"uuid":"391074131","full_name":"meistermeier/spring-graphql-neo4j","owner":"meistermeier","description":"Example project using Spring Data Neo4j and Spring GraphQL","archived":false,"fork":false,"pushed_at":"2024-11-21T22:12:15.000Z","size":325,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T05:24:26.713Z","etag":null,"topics":["java","spring-boot","spring-graphql"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meistermeier.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-30T13:27:35.000Z","updated_at":"2025-03-11T13:37:53.000Z","dependencies_parsed_at":"2025-03-10T16:35:17.652Z","dependency_job_id":"f658ae7e-00bb-477c-9ad5-c5fdcf908c78","html_url":"https://github.com/meistermeier/spring-graphql-neo4j","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meistermeier%2Fspring-graphql-neo4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meistermeier%2Fspring-graphql-neo4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meistermeier%2Fspring-graphql-neo4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meistermeier%2Fspring-graphql-neo4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meistermeier","download_url":"https://codeload.github.com/meistermeier/spring-graphql-neo4j/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252799598,"owners_count":21806023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","spring-boot","spring-graphql"],"created_at":"2024-10-03T16:17:16.696Z","updated_at":"2025-05-07T02:23:40.197Z","avatar_url":"https://github.com/meistermeier.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"== Spring GraphQL with Spring Data Neo4j\n\nThis example project shows how to combine https://docs.spring.io/spring-graphql/docs/1.2.0/reference/html/[Spring GraphQL 1.2.0] with https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#reference[Spring Data Neo4j 7.1.0].\nThe project itself is based on Spring Boot 3.1 to make use of some very nice improvements.\n\n=== Planned features / tasks for this example\n\n* Support for Scroll/Pagination https://docs.spring.io/spring-graphql/docs/current/reference/html/#data.pagination.scroll\n** Need to https://github.com/spring-projects/spring-data-neo4j/issues/2726[implement some functionality] in Spring Data Neo4j first\n* Native image support without additional definitions\n** Spring Data Neo4j https://github.com/spring-projects/spring-data-neo4j/issues/2725[misses some hints] to compile out-of-the-box with Spring GraphQL\n\n=== Some features and libraries used in this example\n\n==== New Testcontainers support features\n\n* `@ServiceConnection`: https://docs.spring.io/spring-boot/docs/3.1.x/reference/htmlsingle/#features.testing.testcontainers.service-connections\n* Testcontainers at development time: https://docs.spring.io/spring-boot/docs/3.1.x/reference/htmlsingle/#features.testing.testcontainers.at-development-time\n* `@ImportTestcontainers`: https://docs.spring.io/spring-boot/docs/3.1.x/reference/htmlsingle/#features.testing.testcontainers.at-development-time.importing-container-declarations\n\n==== Neo4j-Migrations for test data creation\n\nStarting the application from the tests or running integration tests, the project will use https://github.com/michael-simons/neo4j-migrations[Neo4j-Migrations] to create the initial dataset.\n\n==== Neo4j Java driver metrics / health\n\n===== Micrometer metrics\n\nAlthough the current version of the Neo4j Java driver is 5.7.,\nthe Spring Boot autoconfiguration is backwards compatible to the whole 4.x versions.\nAs a consequence, it cannot configure the metrics provider automatically and we need to provide a `ConfigBuilderCustomizer`\nto set `Micrometer` as the adapter.\n\n[source,java]\n----\n@Bean\nConfigBuilderCustomizer configBuilderCustomizer() {\n    return configBuilder -\u003e configBuilder.withMetricsAdapter(MetricsAdapter.MICROMETER);\n}\n----\n\nThis will provide following metrics to consume.\nAccessible via http://localhost:8080/actuator/metrics/\u003cneo4j.driver.metric\u003e\n\n[source,text]\n.Overview of available Neo4j driver metrics\n----\nneo4j.driver.connections.acquiring\nneo4j.driver.connections.acquisition\nneo4j.driver.connections.acquisition.timeout\nneo4j.driver.connections.closed\nneo4j.driver.connections.creating\nneo4j.driver.connections.creation\nneo4j.driver.connections.failed\nneo4j.driver.connections.idle\nneo4j.driver.connections.in.use\nneo4j.driver.connections.usage\n----\n\n===== Health\n\nThe health endpoint is enriched with the information about the connection to the running Neo4j instance\nand can be queried at http://localhost:8080/actuator/health/neo4j.\n\nPlease be aware that both, metrics and health endpoints, are configured without any security mechanisms in this project's configuration.\nAlways check the information you are exposing before deploying an application to the public.\n\n=== Try it out\n\n==== With a temporary test database\n\nThe project provides a Neo4j testcontainer instance if it gets started from the tests. (Docker needed)\n\n[source,shell]\n----\n./mvnw spring-boot:test-run\n----\n\n==== With a \"production\" database\n\nIf you want to connect to a running instance, you have to start the application with the matching environment variables\n\n[source,shell]\n----\nSPRING_NEO4J_AUTHENTICATION_PASSWORD=\u003cyour password\u003e \\\\\nSPRING_NEO4j_URI=\u003cyour uri, default bolt://localhost:7687\u003e \\\\\n./mvnw spring-boot:run\n----\n\nPlease keep in mind that the application is focused on using the movie dataset.\nIf not happen yet, please run the `:play movies` guide and the Cypher query to populate the database.\n\n==== Compile native\n\nThis requires you to have GraalVM (Java 17 based) installed and included your _$PATH_ on your machine.\nThere is a pre-configured profile (_native_) that will invoke the GraalVM's native maven plugin.\n\n[source,shell]\n.invoke native compile\n----\n./mvnw -Pnative clean package\n----\n\nAfter it has successfully compiled, you can invoke the executable similar to the command above.\n\n[source,shell]\n.start the application\n----\nSPRING_NEO4J_AUTHENTICATION_PASSWORD=\u003cyour password\u003e \\\\\nSPRING_NEO4j_URI=\u003cyour uri, default bolt://localhost:7687\u003e \\\\\ntarget/spring-neo4j-graphql\n----\n\n=== What to explore\n\nThe current schema looks like this:\n\n[source,graphql endpoint]\n.schema.graphqls\n----\ntype Query {\n    movies : [Movie]\n    movie(title : String!) : Movie\n}\n\ntype Movie {\n    id: ID!\n    title: String!\n    description : String!\n    \"Random number 0 - 100 as an example for aggregation of data\"\n    rating: Int\n    actors: [Person]\n    directors: [Person]\n}\n\n\"A person is either an actor or a director\"\ntype Person {\n    id: ID!\n    name: String!\n    yearOfBirth: Int\n}\n----\n\nExample queries as you can see above are:\n\n[source,graphql]\n.Query all movies\n----\n{movies {title, actors {name, yearOfBirth}}}\n----\nwill return:\n\n[source, json]\n----\n{\n  \"data\": {\n    \"movies\": [\n      {\n        \"title\": \"The Matrix\",\n        \"actors\": [\n          {\n            \"name\": \"Gloria Foster\",\n            \"yearOfBirth\": null\n          },\n          {\n            \"name\": \"Hugo Weaving\",\n            \"yearOfBirth\": 1960\n          },\n          {\n            \"name\": \"Keanu Reeves\",\n            \"yearOfBirth\": 1964\n          },\n          {\n            \"name\": \"Emil Eifrem\",\n            \"yearOfBirth\": 1978\n          }, ...\n     ]},\n     {\n        \"title\": \"The Matrix Reloaded\",\n        \"actors\": [\n          {\n            \"name\": \"Gloria Foster\",\n            \"yearOfBirth\": null\n          }, ....\n        ]}\n    ]}\n}\n----\n\n[source,graphql]\n.Query one particular movie\n----\n{movie (title: \"The Matrix\") {title, description}}\n----\n\nwill return:\n\n[source, json]\n----\n{\n  \"data\": {\n    \"movie\": {\n      \"title\": \"The Matrix\",\n      \"description\": \"Welcome to the Real World\"\n    }\n  }\n}\n----\n\n==== Multiple sources\n\nIt is possible to aggregate the data from different sources.\nFor example the `rating` field of the `Movie` will be a random generated number between 0 and 100.\n\n[source,graphql]\n.Query movie with field from other source\n----\n{movie (title: \"The Matrix\") {title, rating}}\n----\n\nreturns\n\n[source, json]\n----\n{\n  \"data\": {\n    \"movie\": {\n      \"title\": \"The Matrix\",\n      \"rating\": 99\n    }\n  }\n}\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeistermeier%2Fspring-graphql-neo4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeistermeier%2Fspring-graphql-neo4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeistermeier%2Fspring-graphql-neo4j/lists"}