Skip to content

Commit

Permalink
parse object directives
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki committed Jan 16, 2024
1 parent b52b375 commit b701e7a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,10 @@ func (s *Schema) Parse(p *Parser) {
t.Filename = p.lex.filename
t.Line = p.lex.line
t.Column = p.lex.col
t.Descriptions = p.bufString()
name, _ := p.lex.consumeIdent()
t.Name = name.String()
t.Descriptions = p.bufString()
t.Directives = p.parseDirectives()

next := p.lex.next()
switch next.typ {
Expand All @@ -364,6 +365,7 @@ func (s *Schema) Parse(p *Parser) {
name, _ = p.lex.consumeIdent()
t.ImplTypes = append(t.ImplTypes, name.String())
}
t.Directives = p.parseDirectives()
p.lex.consumeToken(tokLBrace)
fallthrough
case tokLBrace:
Expand Down
1 change: 1 addition & 0 deletions lib/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (ms *MergedSchema) WriteSchema(s *Schema) string {
if len(t.ImplTypes) > 0 {
ms.buf.WriteString(" implements " + strings.Join(t.ImplTypes, " & "))
}
ms.stitchDirectives(t.Directives)
ms.buf.WriteString(" {\n")
for _, p := range t.Fields {
ms.writeDescriptions(p.Descriptions, 1, false)
Expand Down
14 changes: 14 additions & 0 deletions test/directives/generated.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type Person @paint {
name: String
age: Int
picture: Url
}

type ExampleType implements Node @deprecated {
id: ID
oldField: String
}




10 changes: 10 additions & 0 deletions test/directives/schema/object.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type Person @paint {
name: String
age: Int
picture: Url
}

type ExampleType implements Node @deprecated {
id: ID
oldField: String
}

0 comments on commit b701e7a

Please sign in to comment.