{"id":23396495,"url":"https://github.com/mneedham/neo4j-graphql","last_synced_at":"2025-04-08T17:32:38.836Z","repository":{"id":66523790,"uuid":"88902386","full_name":"mneedham/neo4j-graphql","owner":"mneedham","description":null,"archived":false,"fork":false,"pushed_at":"2017-05-15T12:00:14.000Z","size":429,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"idl-roundtrip","last_synced_at":"2025-02-14T13:50:21.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mneedham.png","metadata":{"files":{"readme":"readme.adoc","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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":"2017-04-20T19:20:06.000Z","updated_at":"2017-04-21T13:17:04.000Z","dependencies_parsed_at":"2023-03-29T04:02:22.025Z","dependency_job_id":null,"html_url":"https://github.com/mneedham/neo4j-graphql","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/mneedham%2Fneo4j-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fneo4j-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fneo4j-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fneo4j-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mneedham","download_url":"https://codeload.github.com/mneedham/neo4j-graphql/tar.gz/refs/heads/idl-roundtrip","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247892507,"owners_count":21013714,"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":[],"created_at":"2024-12-22T07:35:57.405Z","updated_at":"2025-04-08T17:32:38.817Z","avatar_url":"https://github.com/mneedham.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Neo4j-GraphQL Extension\n\nimage:https://travis-ci.org/neo4j-contrib/neo4j-graphql.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/neo4j-contrib/neo4j-graphql\"]\n\nNOTE: This is an very early version of GraphQL support for Neo4j.\n\nThis implementation provides a GraphQL API to Neo4j, it comes as library but can also be installed as Neo4j server extension\nto act as a GraphQL endpoint.\n\nWe want to explore three approaches:\n\n1. read schema / metadata from the database provide GraphQL DataFetcher that generate and run Cypher (WIP) √\n2. make the same work with externally configured schema information (using IDL) √\n3. do a direct GraphQL AST to Cypher transformation without bothering with Schema (TBD)\n\nNOTE: Currently only Node and simple Relationship queries are supported.\nDeeper Relationship queries and aggregations are up next.\n\n== License\n\nApache License v2\n\n== Schema\n\nThe library samples the existing data and adds one GraphQLObject for each Node-Label with all the properties and their types found as outputs and input-arguments.\n\nRelationship information is collected with direction, type, end-node-labels and degree (to determine single element or collection result).\n// Additional labels on a node are added as GraphQLInterface's.\nEach relationship-type and end-node label is added as a virtual property to the node type, named `TYPE_Label` for outgoing and `Label_TYPE` for incoming relationships.\n\n== Installation\n\nThe current version of this extension works with Neo4j 3.0 and 3.1\n\n----\ngit clone https://github.com/neo4j-contrib/neo4j-graphql\ncd neo4j-graphql\nmvn clean package\ncp target/neo4j-graphql-1.0-SNAPSHOT.jar $NEO4J_HOME/plugins\necho 'dbms.unmanaged_extension_classes=org.neo4j.graphql=/graphql' \u003e\u003e $NEO4J_HOME/config/neo4j.conf\n$NEO4J_HOME/bin/neo4j restart\n----\n\n== Features\n\n[options=header,cols=\"a,2a,3m\"]\n|===\n| name | information | example\n| entities | each node label represented as entity | { User {name,age} }\n| multi entities | multiple entities per query turned into `UNION` | { User {name,age} City {name,geo} }\n| properties (out) | via sampling property names and types are determined | { City {name,geo} }\n| properties (in) | all properties can be used as filtering (exact/list) input parameters, will be turned into Cypher parameters | { City(name:\"Berlin\") {name,geo} }\n| parameters | passed through as Cypher parameters | query UserQuery ($name: String!) { User(name:$name) {name,age} }\n| relationships (out) | via a `RELTYPE_Label` nested field | { User { name, LIVES_IN_City {name} } }\n| relationships (in) | via a `Label_RELTYPE` nested field | { City { name, User_LIVES_IN { name } } }\n| ordering | via an extra `orderBy` input field | query UserSortQuery { User(orderBy:[name_desc,age_desc]) {name,age}}\n| directive | directives control cypher prefixes, *note that directives have to be set at the first entity* |\n| directive - query plan | `@profile / @explain` will be returned in extra field `extensions` | query UserQuery { User @profile {name} }\n\n// | directive - version | set cypher version to use `@version(3.0,3.1,3.2)` | query UserQuery { User @version(3.0) {name} }\n// | directive - compiled runtime  | force compiled runtime to be used | query UserQuery { User @compile {name} }\n| extensions | extra information returned | fields are: columns, query, warnings, plan, type READ_ONLY/READ_WRITE,\n| IDL | define schema via IDL | :POST /graphql/idl \"type Person {name: String!, born: Int}\"\n|===\n\n== Usage\n\nRun `:play movies` in your Neo4j Server, click the statement and run it to insert the basic movie graph.\n\n== GraphiQL\n\nGet GraphiQL electron app from: https://github.com/skevy/graphiql-app\n\nIf your Neo4j Server runs with auth enabled, add the appropriate Basic-Auth header in the \"Edit HTTP Headers\" screen.\n\n----\necho \"Authorization: Basic $(echo -n \"neo4j:\u003cpassword\u003e\" | base64)\"\n----\n\nAnd then run a query like:\n\n----\nquery AllPeopleQuery {\n  Person(name:\"Kevin Bacon\") {\n    name\n    born\n    ACTED_IN_Movie {\n      title\n      released\n      tagline\n    }\n  }\n}\n----\n\nimage::graphiql.jpg[width=600]\n\nYou can also use variables or query the schema:\n\n.Which types are in the schema\n----\n{\n  __schema {\n    types {\n      name\n      kind\n      description\n    }\n  }\n}\n----\n\nor\n\n.Which types are available for querying\n----\n{\n  __schema {\n    queryType {\n      fields { name, description }\n    }\n  }\n}\n----\n\nand then query for real data\n\n----\n# query\nquery PersonQuery($name: String!) {\n  Person(name: $name) {\n    name\n    born\n    ACTED_IN_Movie {\n      title\n      released\n      tagline\n    }\n  }\n}\n# variables\n{\"name\":\"Keanu Reeves\"}\n----\n\n== Procedure\n\nThis library also comes with a User Defined Procedure to execute GraphQL:\n\n[source,cypher]\n----\nWITH '{ Person(born: 1961) { name, born } }' as query, {} as params\n\nCALL graphql.execute(query,params) YIELD result\n\nUNWIND result.Person as p\nRETURN p.name, p.born\n----\n\nimage::graphql.execute.jpg[width=600]\n\n== Examples\n\nSome more examples\n\n.Relationship Argument\n----\nquery MoviePersonQuery {\n  Movie {\n    title\n    Person_ACTED_IN(name:\"Tom Hanks\") {\n      name\n    }\n  }\n}\n----\n\n.Nested Relationships\n----\nquery PersonMoviePersonQuery {\n  Person {\n    name\n    ACTED_IN_Movie {\n      title\n      Person_ACTED_IN {\n        name\n      }\n    }\n  }\n}\n----\n\n.Sorting\n----\nquery PersonQuery {\n  Person(orderBy: [age_asc, name_desc]) {\n    name\n    born\n  }\n}\n----\n\n== CURL\n\n=== POST IDL\n_(Optional if no data in database)_\n\n----\ncurl  -u neo4j:\u003cpassword\u003e -i -XPOST -d'type Person { name: String, born: Int }' http://localhost:7474/graphql/idl/\n\n{Person=MetaData{type='Person', ids=[], indexed=[], properties={name=PropertyType(name=String, array=false, nonNull=false), born=PropertyType(name=Int, array=false, nonNull=false)}, labels=[], relationships={}}}\n----\n\n\n=== Query the Schema\n\n----\ncurl  -u neo4j:\u003cpassword\u003e -i -XPOST -d'{\"query\": \"query {__schema {types {kind, name, description}}}\"}' -H accept:application/json -H content-type:application/json http://localhost:7474/graphql/\n\n{\"data\":{\"__schema\":{\"types\":[{\"kind\":\"OBJECT\",\"name\":\"QueryType\",\"description\":null},{\"kind\":\"OBJECT\",\"name\":\"Movie\",\"description\":\"Movie-Node\"},....\n----\n\n----\nquery {__schema {queryType {\n  kind,description,fields {\n    name\n  }\n}}}\n----\n\n=== Get All People\n\n----\ncurl  -u neo4j:\u003cpassword\u003e  -i -XPOST -d'{\"query\": \"query AllPeopleQuery { Person {name,born} } }\"}' -H accept:application/json -H content-type:application/json http://localhost:7474/graphql/\n\n\nHTTP/1.1 200 OK\nDate: Mon, 24 Oct 2016 21:40:15 GMT\nContent-Type: application/json\nAccess-Control-Allow-Origin: *\nTransfer-Encoding: chunked\nServer: Jetty(9.2.9.v20150224)\n\n{\"data\":{\"Person\":[{\"name\":\"Michael Sheen\",\"born\":1969},{\"name\":\"Jack Nicholson\",\"born\":1937},{\"name\":\"Nathan Lane\",\"born\":1956},{\"name\":\"Philip Seymour Hoffman\",\"born\":1967},{\"name\":\"Noah Wyle\",\"born\":1971},{\"name\":\"Rosie O'Donnell\",\"born\":1962},{\"name\":\"Greg Kinnear\",\"born\":1963},{\"name\":\"Susan Sarandon\",\"born\":1946},{\"name\":\"Takeshi Kitano\",\"born\":1947},{\"name\":\"Gary Sinise\",\"born\":1955},{\"name\":\"John Goodman\",\"born\":1960},{\"name\":\"Christina Ricci\",\"born\":1980},{\"name\":\"Jay Mohr\",\"born\":1970},{\"name\":\"Ben Miles\",\"born\":1967},{\"name\":\"Carrie Fisher\",\"born\":1956},{\"name\":\"Christopher Guest\",\"born\":1948},{\"name\n...\n----\n\n=== Get one Person by name with Parameter\n\n----\ncurl  -u neo4j:\u003cpassword\u003e -i -XPOST -d'{\"query\":\"query PersonQuery($name:String!) { Person(name:$name) {name,born} }\", \"variables\":{\"name\":\"Kevin Bacon\"}}' -H content-type:application/json http://localhost:7474/graphql/\n\nHTTP/1.1 200 OK\nDate: Mon, 24 Oct 2016 21:40:38 GMT\nContent-Type: application/json\nAccess-Control-Allow-Origin: *\nTransfer-Encoding: chunked\nServer: Jetty(9.2.9.v20150224)\n\n{\"data\":{\"Person\":[{\"name\":\"Kevin Bacon\",\"born\":1958}]}}\n----\n\n=== Get one Person by name literal with related movies\n\n----\ncurl  -u neo4j:\u003cpassword\u003e -i -XPOST -d'{\"query\":\"query PersonQuery { Person(name:\\\"Tom Hanks\\\") {name, born, ACTED_IN_Movie {title, released} } }\"}' -H content-type:application/json http://localhost:7474/graphql/\nHTTP/1.1 200 OK\nDate: Tue, 25 Oct 2016 03:17:08 GMT\nContent-Type: application/json\nAccess-Control-Allow-Origin: *\nTransfer-Encoding: chunked\nServer: Jetty(9.2.9.v20150224)\n\n{\"data\":{\"Person\":[{\"name\":\"Tom Hanks\",\"born\":1956,\"ACTED_IN_Movie\":[{\"title\":\"Charlie Wilson's War\",\"released\":2007},{\"title\":\"A League of Their Own\",\"released\":1992},{\"title\":\"The Polar Express\",\"released\":2004},{\"title\":\"The Green Mile\",\"released\":1999},{\"title\":\"Cast Away\",\"released\":2000},{\"title\":\"Apollo 13\",\"released\":1995},{\"title\":\"The Da Vinci Code\",\"released\":2006},{\"title\":\"Cloud Atlas\",\"released\":2012},{\"title\":\"Joe Versus the Volcano\",\"released\":1990},{\"title\":\"Sleepless in Seattle\",\"released\":1993},{\"title\":\"You've Got Mail\",\"released\":1998},{\"title\":\"That Thing You Do\",\"released\":1996}]}]}}\n----\n\n== Resources\n\n* https://github.com/graphql-java/graphql-java[GraphQL-Java] which we use in this project\n\n\n* https://github.com/solidsnack/GraphpostgresQL[GraphQL for Postgres] as an inspiration of schema -\u003e native queries\n* https://github.com/jhwoodward/neo4j-graphQL[Schema Based GraphQL to Cypher in JavaScript]\n* https://github.com/jameskyburz/graphqlcypherquery[GraphQL to Cypher translator (w/o schema)]\n** https://github.com/JamesKyburz/graphql2cypher[GraphQL parser to Cypher]\n\n* https://neo4j.com/blog/cypher-graphql-neo4j-3-1-preview/[GraphQL inspired Cypher features] Map projections and Pattern comprehensions\n* https://github.com/facebook/dataloader\n\n* https://github.com/skevy/graphiql-app[GraphiQL Electron App]\n* http://graphql.org/learn/serving-over-http/[Serving over HTTP]\n\n* https://facebook.github.io/graphq[GraphQL Specification]\n////\necho \"Authorization: Basic $(echo -n \"neo4j:test\" | base64)\"\n\"Authorization: Basic bmVvNGo6dGVzdA==\"\n////\n\n== TODO\n\n* Non-Null and Nullable Input and Output Types\n* https://www.reindex.io/docs/graphql-api/connections/#connection-arguments[Pagination]: Skip and Limit (first,last,after,before,skip,limit)\n* √ https://www.reindex.io/docs/graphql-api/connections/#orderby[orderBy] with enum _PersonOrdering { name_asc,name_desc,... }\n* https://www.reindex.io/docs/graphql-api/connections/#filtering[Filtering] with support of a object argument for an input-argument-field, with key=comparator, and value compare-value +\n  `(status: {eq/neq:true}, createdAt: { gte: \"2016-01-01\", lt: \"2016-02-01\"}, tags: {isNull:false, includes/excludes: \"foo\"})`\n* Handle result aggregation.\n* How to handle Geospatial and other complex input types\n* √ Support for Directives, e.g. to specify the cypher compiler or runtime? or special handling for certain fields or types\n* √ Add `extensions` result value for query statistics or query plan, depending on directives given, e.g. contain the generated cypher query as well\n* @skip, @include directives, check if they are handled by the library\n* handle nested relationships as optional or non-optional (perhaps via nullable?) or directive\n* √ project non-found nested results as null vs. map with null-value entries\n* https://facebook.github.io/relay/docs/graphql-connections.html#content[Connection] add support for edges / nodes special properties\n* Support 3.1 via pattern comprehensions and map projections\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmneedham%2Fneo4j-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmneedham%2Fneo4j-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmneedham%2Fneo4j-graphql/lists"}