Skip to content

Commit

Permalink
Remove field_camel and add field_proto CLI arg (#14)
Browse files Browse the repository at this point in the history
* convert field_camel to field_json_name

* Refactor gql field name generation
- make json_name the default
- field_proto optional arg to use protobuf names

* remove gitignore changes

* run go tests

* revert to use buf remote code generation

* remove comment from graphql.proto

* add CHANGELOG entry
  • Loading branch information
alehechka authored Aug 1, 2022
1 parent 702c8f1 commit 184b831
Show file tree
Hide file tree
Showing 33 changed files with 673 additions and 313 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Tests
run: make test

- name: Build example/starwars
run: make build_all
working-directory: example/starwars
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## UNRELEASED

- Resolve camelCase enum values ([#13](https://github.com/alehechka/grpc-graphql-gateway/pull/13))
- Remove field_camel and add field_proto CLI arg ([#14](https://github.com/alehechka/grpc-graphql-gateway/pull/14))

## [v0.2.4](https://github.com/alehechka/grpc-graphql-gateway/releases/tag/v0.2.4)

Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ lint:
golangci-lint run

test:
cd runtime/tests ; make build
go list ./... | xargs go test

build: test plugin
Expand All @@ -41,3 +42,7 @@ compile:

compile_mac:
cd ${GRAPHQL_CMD} && GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.version=${VERSION}" -o ${GOPATH}/bin/${GRAPHQL_CMD}

build_examples:
cd example/starwars ; make build_all
cd example/greeter ; make build_all
8 changes: 4 additions & 4 deletions example/greeter/greeter/greeter.graphql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion example/starwars/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ build: init
--plugin=../../dist/protoc-gen-graphql \
--graphql_out=${SPECDIR} \
--graphql_opt=paths=source_relative \
--graphql_opt=field_camel \
--go_out=:${SPECDIR} \
--go_opt=paths=source_relative \
--go-grpc_out=:${SPECDIR} \
Expand Down
1 change: 0 additions & 1 deletion example/starwars/app/grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func (s *Server) ListHumans(
}
cs = append(cs, c)
}
log.Println(cs)
return &starwars.ListHumansResponse{
Humans: cs,
}, nil
Expand Down
8 changes: 4 additions & 4 deletions example/starwars/proto/starwars/starwars.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ message Character {
int64 id = 1;
string name = 2;
repeated Character friends = 3;
repeated Episode appears_in = 4;
string home_planet = 5;
repeated Episode appears_in = 4 [json_name = "appearances"];
string home_planet = 5 [json_name = "home"];
string primary_function = 6;
Type type = 7;
}
Expand All @@ -35,12 +35,12 @@ message GetHeroRequest {

message GetHumanRequest {
// id of the human
int64 id = 1 [(graphql.field) = {required: true}];
int64 id = 1 [json_name = "humanID", (graphql.field) = {required: true}];
}

message GetDroidRequest {
// id of the droid
int64 id = 1 [(graphql.field) = {required: true}];
int64 id = 1 [json_name = "droidID", (graphql.field) = {required: true}];
}

message ListEmptyRequest {
Expand Down
34 changes: 17 additions & 17 deletions example/starwars/spec/starwars/starwars.graphql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 184b831

Please sign in to comment.