github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/greeter/api/graphql/README.md (about) 1 # GraphQL with gqlgen 2 3 Uses the gRPC models with a GraphQL schema. 4 5 ## Dependencies 6 7 ``` 8 go get -u github.com/99designs/gqlgen github.com/vektah/gorunpkg 9 ``` 10 11 ## Running the example 12 13 ### 1. Start the RPC server 14 15 ``` 16 go run srv/main.go 17 ``` 18 19 ### 2. Start the GraphQL server 20 21 ``` 22 go run api/graphql/main.go 23 ``` 24 25 ## Query 26 27 Now you can query your GraphQL API 28 29  30 31 When a GraphQL request comes in, the gRPC handler is called with your request, according to `resolver.go` and a populated model is returned. 32 33 Basic error handling can be seen if you turn off your gRPC service and try to query. 34 35 ## Making changes to the GraphQL schema 36 37 If you change the GraphQL schema file (graphql.schema), then you need to be aware of the following 38 39 `gqlgen.yml` tells gqlgen where your models are and if you don't specify, it will create them for you. In this example, I decided to use the protobuf generated models across the board. You might want to do that differently. 40 41 `resolver.go` is generated for you if you don't have it the first time. You need to implement your own resolvers. No way around that, but we have Go types for them, so that's nice. 42 43 To update your generated.go, run `gqlgen` inside graphql/graphql.