https://github.com/wenerme/goaphql
Golang with GraphQL
https://github.com/wenerme/goaphql
codegen golang graphql graphql-tools parser
Last synced: 12 months ago
JSON representation
Golang with GraphQL
- Host: GitHub
- URL: https://github.com/wenerme/goaphql
- Owner: wenerme
- License: apache-2.0
- Created: 2018-03-21T14:54:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-15T10:13:51.000Z (over 5 years ago)
- Last Synced: 2025-06-28T05:43:45.129Z (12 months ago)
- Topics: codegen, golang, graphql, graphql-tools, parser
- Language: Go
- Homepage: https://github.com/wenerme/goaphql
- Size: 153 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoaphQL
Read in | [中文](./README.zh-CN.md) | [English](./README.md)
## Command Line
```bash
# Installation
go get -u -v github.com/wenerme/goaphql/cmd/goaphql
```
## graphql-java
```bash
# Generate
# Package com.github
# Name Github
goaphql generate graphql-java -s github.graphqls -P com.github -N GitHub
# same
goaphql g gj -s github.graphqls -P com.github -N GitHub
# Customization
# Dump templates
goaphql dump -t tmpl/graphql-java --prefix tmpl/graphql-java -d ./tpl
# Modify templats
# Add package-info.java
echo -e 'package {{Config.JavaPackage}};' > './tpl/Java#package-info.java.tmpl'
# Generate using modified templates
goaphql generate graphql-java -t ./tpl -s github.graphqls -P com.github -N GitHub
# Check the new file
cat out/me/wener/package-info.java
```
### Dependencies
Generated depends on [wenerme/jraphql](https://github.com/wenerme/jraphql) .
```xml
me.wener.jraphql
jraphql-graphql-java-adapter
0.0.2
org.projectlombok
lombok
1.16.20
provided
```
## Inside
Package | Description
--------|------------
gqlp | GraphQL Parser
gqll | GraphQL Language representation
gqlg | GraphQL Code generator
cmd/goaphql | Command line tool
## GraphQL Language Extension
* Antlr Grammar [GraphQL.g4](https://github.com/wenerme/wener/blob/master/tricks/languages/antlr/GraphQL.g4)
```graphqls
# 1. extend by name syntax
type MyQuery {
myUser(id:ID!):MyUser
}
extend Query by MyQuery
# 2. Allowed directives on directive definition, add DIRECTIVE_DEFINITION location
directive @JavaType(type:String) on DIRECTIVE_DEFINITION
directive @Auth(value:String) @JavaType(type:"Auth") on FIELD_DEFINITION;
# 3. Allowed schema has optional name
schema Test {
query: MyQuery
}
```
## Roadmap
* [ ] Parse comment
* [ ] Extract java runtime to [jraphql](https://github.com/wenerme/jraphql)
* [ ] Implement golang runtime
* [ ] Implement golang codegen
* [ ] Implement graphql codegen