Skip to content

Commit

Permalink
Fix property name as type (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki authored Oct 9, 2023
1 parent 6d53d00 commit 2015ef4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/check-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version}}

- name: Run make build
run: |
make build
- name: Run make test
run: |
make test
- name: Run make check-diff
run: |
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 @@
## v0.2.11

- Fixed mis-used rune `[` instead of tokLBracket https://github.com/mununki/gqlmerge/pull/41
- Fixed merge error when the property name as `type` https://github.com/mununki/gqlmerge/pull/45

## v0.2.10

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ all: build test check-diff
build:
go build

test: build
test:
@for dir in $(shell find test -type d -name schema); do \
basedir=`dirname $$dir`; \
output="$$basedir/generated.graphql"; \
echo "Merging $$dir into $$output..."; \
./gqlmerge $$dir $$output; \
./gqlmerge $$dir $$output || exit 1; \
done

check-diff: build test
check-diff:
@if git diff --exit-code --quiet -- '*.graphql'; then \
echo "Ok"; \
else \
Expand Down
6 changes: 3 additions & 3 deletions lib/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (s *Schema) Parse(p *Parser) {
fd.Filename = p.lex.filename
fd.Line = p.lex.line
fd.Column = p.lex.col
name, comments := p.lex.consumeIdent()
name, comments := p.lex.consumeIdent(tokInput, tokType)
fd.Name = name.String()
fd.Descriptions = comments

Expand Down Expand Up @@ -291,7 +291,7 @@ func (s *Schema) Parse(p *Parser) {
fd.Filename = p.lex.filename
fd.Line = p.lex.line
fd.Column = p.lex.col
name, comments := p.lex.consumeIdent()
name, comments := p.lex.consumeIdent(tokInput, tokType)
fd.Name = name.String()
fd.Descriptions = comments
p.lex.consumeToken(tokColon)
Expand Down Expand Up @@ -372,7 +372,7 @@ func (s *Schema) Parse(p *Parser) {
fd.Filename = p.lex.filename
fd.Line = p.lex.line
fd.Column = p.lex.col
name, comments := p.lex.consumeIdent()
name, comments := p.lex.consumeIdent(tokInput, tokType)
fd.Name = name.String()
fd.Descriptions = comments

Expand Down
22 changes: 22 additions & 0 deletions test/property_type/generated.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
schema {
query: Query
mutation: Mutation
subscription: Subscription
}

type SomePayload {
type: String!
someKey: String!
}



interface I {
type: String!
input: String!
}

input I {
type: String!
input: String!
}
4 changes: 4 additions & 0 deletions test/property_type/schema/Input.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
input I {
type: String!
input: String!
}
4 changes: 4 additions & 0 deletions test/property_type/schema/Interface.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface I {
type: String!
input: String!
}

0 comments on commit 2015ef4

Please sign in to comment.