{"id":20903733,"url":"https://github.com/mihajlonesic/numista-graphql","last_synced_at":"2026-05-06T19:34:42.487Z","repository":{"id":107264024,"uuid":"555337197","full_name":"MihajloNesic/numista-graphql","owner":"MihajloNesic","description":"Demo project for GraphQL with Spring Boot","archived":false,"fork":false,"pushed_at":"2022-11-10T09:10:31.000Z","size":524,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-19T13:52:53.258Z","etag":null,"topics":["graphql","graphql-java","graphql-java-kickstart","numista","spring-boot"],"latest_commit_sha":null,"homepage":"","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/MihajloNesic.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-21T11:36:48.000Z","updated_at":"2025-01-14T10:22:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"dcf27bc4-00fc-4dfd-b75d-456f847ec4db","html_url":"https://github.com/MihajloNesic/numista-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/MihajloNesic%2Fnumista-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MihajloNesic%2Fnumista-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MihajloNesic%2Fnumista-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MihajloNesic%2Fnumista-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MihajloNesic","download_url":"https://codeload.github.com/MihajloNesic/numista-graphql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243293986,"owners_count":20268175,"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":["graphql","graphql-java","graphql-java-kickstart","numista","spring-boot"],"created_at":"2024-11-18T13:14:46.402Z","updated_at":"2025-12-11T20:00:55.513Z","avatar_url":"https://github.com/MihajloNesic.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## numista-graphql\nA demo project for GraphQL with Spring Boot\n\n![](images/graphiql.png)\n\nGraphQL topics covered in this implementation:\n- [x] Query\n- [x] Mutation\n- [ ] Subscription\n- [x] Directive\n- [x] Scalar\n- [x] Enum\n\n### Getting started\n\nRun `build_and_run.sh` to build a docker image and run it on port 8089\n\nAlternatively, build a project with `mvn clean install` and then execute `java -jar ./target/numista-graphql.jar`. You will need Java 11.\n\n### Project structure\n\n#### Source files\n| Package    | Description                                                                                                                   |\n|------------|-------------------------------------------------------------------------------------------------------------------------------|\n| entity     | Database entities                                                                                                             |\n| exception  | Contains exceptions used in GraphQL queries and mutations                                                                     |\n| model      | Request and response objects                                                                                                  |\n| repository | Database persistence interfaces                                                                                               |\n| resolver   | Contains resolver classes for queries, mutations, directives and scalars                                                      |\n| rest       | Contains a rest implementation of one service (to use as a comparison; this package is not needed for GraphQL implementation) |\n| security   | Most simple security implementation with stateful API tokens                                                                  |\n| service    | Business logic                                                                                                                |\n\n#### Resources\n| file/folder          | Description                                                                                                                                      |\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| application.yml      | Spring configuration for local/dev environment                                                                                                   |\n| application-prod.yml | Spring configuration for staging/production environment. You will need to set profile `prod` to active. The GraphiQL and H2 console are disabled |\n| schema.sql           | Database schema used for an application                                                                                                          |\n| data.sql             | Sample data for this application                                                                                                                 |\n| graphql/             | A directory containing all GraphQL schema definitions (models, queries, mutations, directives, enums, scalars)                                   |\n| playground/          | A directory to automatically populate GraphiQL with example queries and request parameters                                                       |\n\n\n### Relations and database\n\nRelations are defined as this: One `issuing authority` is issuing (or minting) various `coins`. Each coin can be `minted` in different year and can be of different type.\n\nThe application uses `H2 in-memory database` because it is easy to setup. This can easily be substituted by some other RDBMS.\n\n![](images/relations.png)\n\n![](images/db.png)\n\n### Security\n\nSecurity is implemented in a most basic way. The focus of this application was not security, but this security implementation can be used as a demo of what can be achieved with GraphQL.\n\n#### Authentication\n\nIn order for user to make GraphQL calls, a header `x-api-key` needs to be present with a valid API key. The keys are created by admin and are stored in a table `api_key`.\n\nEach key, depending on a `ROLE`, can have a certain amount of `quota` that is limiting the number of daily calls. \n\nEach day at 1am UTC, all the quotas are reset to 0. This is implemented in `ApiKeyService` class.\n\nAlternatively, the API key can be blocked (or inactivated) by an ADMIN role and that API key cannot make calls (until activated).\n\n#### Authorization\n\nDepending on a role (USER or ADMIN), a user has different permissions to ether fetch an attribute from an object or to execute a query or mutation. This is achieved using a custom GraphQL directive called `@auth`.\n\nFor example:\n- a role 'User' and 'Guest' is forbidden to fetch an attribute 'numistaId' from a Coin object -\u003e `numistaId: Int @auth(denyRoles: [\"user\", \"guest\"])`\n- only admin role can execute api key queries and mutations -\u003e `apiKeys: [ApiKey] @auth(allowRoles: [\"admin\"])`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihajlonesic%2Fnumista-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmihajlonesic%2Fnumista-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihajlonesic%2Fnumista-graphql/lists"}