Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buma/graphqlgenerator
Java GraphQL schema generator from Java classes
https://github.com/buma/graphqlgenerator
Last synced: 5 days ago
JSON representation
Java GraphQL schema generator from Java classes
- Host: GitHub
- URL: https://github.com/buma/graphqlgenerator
- Owner: buma
- License: mit
- Created: 2016-01-28T08:41:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-28T08:49:31.000Z (almost 9 years ago)
- Last Synced: 2024-11-07T22:50:25.572Z (about 2 months ago)
- Language: Java
- Homepage:
- Size: 19.5 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphQLGenerator
It is generator for GraphQL schema from Java classes. It is expected that code will use [graphql-java](https://github.com/andimarek/graphql-java).
It is in working, but usage and code can be improved.
To use it you need to edit Main.java and fill typeMap.
TypeMap is map from java class name to the name you want GraphQL object to have.
Each new object needs to be in it. Unless it is scalar (integer, short, float, double, boolean, char).Then you need to call ReadClass or ReadEnum with typeMap and call readFile with path to wanted java file. It prints resulting GraphQL.
ReadClass can be used to read classes which will be objects or operations. In that case you need to call ReadClass with second parameter to true).
In java classes it reads:
* class comments as object description
* public variables
* Comments before each variable (this is description in GraphQL)
* here it also supports @notnull
* and @default: if class is used as GraphQL operation
* it also adds datafetcher that calls public variableIn enums it reads:
* enum comments as object description
* enum values comments as value description
* Value and text value## Future wishes:
* prettier code
* better documentation
* ability to add root java file and it automatically generates Graphql code for it and all its dependencies
* nicer templates
* Support for getters not only public variables## License
MIT