{"id":13769911,"url":"https://github.com/jcrygier/graphql-jpa","last_synced_at":"2025-10-08T01:45:49.940Z","repository":{"id":145711230,"uuid":"42683851","full_name":"jcrygier/graphql-jpa","owner":"jcrygier","description":"JPA Implementation of GraphQL (builds on graphql-java)","archived":false,"fork":false,"pushed_at":"2018-06-11T15:56:49.000Z","size":150,"stargazers_count":169,"open_issues_count":12,"forks_count":47,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-20T14:49:59.118Z","etag":null,"topics":["graphql","graphql-server","jpa"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcrygier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-09-17T21:50:50.000Z","updated_at":"2025-08-13T11:13:58.000Z","dependencies_parsed_at":"2023-04-07T00:04:01.487Z","dependency_job_id":null,"html_url":"https://github.com/jcrygier/graphql-jpa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jcrygier/graphql-jpa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrygier%2Fgraphql-jpa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrygier%2Fgraphql-jpa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrygier%2Fgraphql-jpa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrygier%2Fgraphql-jpa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcrygier","download_url":"https://codeload.github.com/jcrygier/graphql-jpa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrygier%2Fgraphql-jpa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877093,"owners_count":26061380,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["graphql","graphql-server","jpa"],"created_at":"2024-08-03T17:00:32.688Z","updated_at":"2025-10-08T01:45:49.917Z","avatar_url":"https://github.com/jcrygier.png","language":"Java","funding_links":[],"categories":["Schema Libraries"],"sub_categories":["Code First"],"readme":"GraphQL for JPA\n===============\n\nIf you're already using JPA, then you already have a schema defined...don't define it again just for GraphQL!\n\nThis is a simple project to extend [graphql-java](https://github.com/andimarek/graphql-java) and have it derive the\nschema from a JPA model.  It also implements an execution platform to generate and run JPA queries based on\nGraphQL queries.\n\nWhile limited, there is a lot of power bundled within.  This project takes a somewhat opinionated view of GraphQL, by\nintroducing things like Pagination, Aggregations, and Sorting.\n\nThis project is intended on depending on very little: graphql-java, and some javax annotation packages.  The tests depend\non Spring (with Hibernate for JPA), and Spock for testing.  These tests are a good illustration of how this library might\nbe used, but any stack (with JPA) should be able to be utilized.\n\nSchema Generation\n-----------------\n\nUsing a JPA Entity Manager, the models are introspected, and a GraphQL Schema is built.  With this GraphQL schema,\ngraphql-java does most of the work, except for querying.\n\nSchema Documentation\n--------------------\n\nA major part of GraphQL is the ability to have a well documented schema.  This project takes advantage of this, and produces\ndescriptions for each Entity in the schema.  For the built in types (e.g. PaginationObject) these are rather hard-coded\nwithout much control from the end user.\n\nHowever, for each Entity / Member that is in your JPA schema, you can document what it's for.  These descriptions are controlled\nby the `@SchemaDocumentation` attribute on either a class level, or a field level of your model.\n\nThese descriptions will show up in the GraphiQL browser automatically, and generally helps when providing an API to your\nend-users.  See the GraphiQL section below for more details.\n\nPagination\n----------\n\nGraphQL does not specify any language or idioms for performing Pagination.  Therefore, this library takes an opinionated\nview, similar to that of Spring.\n\nEach model (say Human or Droid - see tests) will have two representations in the generated schema:\n\n- One that models the Entities directly (Human or Droid)\n- One that wraps the Entity in a page request (HumanConnection or DroidConnection)\n\nThis allows you to query for the \"Page\" version of any Entity, and return metadata (like total count) alongside of the\nactual requested data.  For example:\n\n    {\n        HumanConnection(paginationRequest: { page: 1, size: 2 }) {\n            totalPages\n            totalElements\n            content {\n                name\n            }\n        }\n    }\n\nWill return:\n\n    {\n        HumanConnection: {\n            totalPages: 3,\n            totalElements: 5,\n            content: [\n                { name: 'Luke Skywalker' },\n                { name: 'Darth Vader' }\n            ]\n        }\n    }\n\nOf course, an extra query is needed to get the total elements, so if you have not requested 'totalPages' or 'totalElements'\nthis query will not be executed.\n\nNOTE: The \"Connection\" name is used here for further extension (Aggregations, etc...).  The name is borrowed\nfrom suggestions by Facebook developers: https://github.com/facebook/graphql/issues/4\n\nAggregations\n------------\n\nNot yet implemented, but will be similar to Pagination\n\nSorting\n-------\n\nSorting is supported on any field.  Simply pass in an 'orderBy' argument with the value of ASC or DESC.  Here's an example\nof sorting by name for Human objects:\n\n    {\n        Human {\n            name(orderBy: DESC)\n            homePlanet\n        }\n    }\n\nQuery Injectors\n---------------\n\nNot yet implemented.  Main use case would be to intercept query execution for security purposes.\n\nGraphiQL\n--------\n\nGraphiQL (https://github.com/graphql/graphiql) has been introduced for simple testing (in the test package, as I don't\nwant to assume your web stack).  Simply launch TestApplication as a Java Application, and navigate to http://localhost:8080/\nto launch.  You will notice a 'Docs' button at the upper right, that when expanded will show you the running schema (Star\nWars in this demo).\n\nYou can enter GraphQL queries in the left pannel, and hit the run button, and the results should come back in the right\npanel.  If your query has variables, there is a minimized panel at the bottom left.  Simply click on this to expand, and\ntype in your variables as a JSON string (don't forget to quote the keys!).  Enjoy!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcrygier%2Fgraphql-jpa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcrygier%2Fgraphql-jpa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcrygier%2Fgraphql-jpa/lists"}