From 9e7a6fd67ace493e602d46abfa7b94748f9aa46a Mon Sep 17 00:00:00 2001 From: Jairus Date: Fri, 29 Nov 2024 21:46:47 -0500 Subject: [PATCH] add docs for fields --- lib/metadata/builder.go | 4 ++-- runtime/graphql/schemagen/schemagen_as_test.go | 12 ++++++++++++ runtime/graphql/schemagen/schemagen_go_test.go | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/metadata/builder.go b/lib/metadata/builder.go index dfd73cdb4..b4024ecd5 100644 --- a/lib/metadata/builder.go +++ b/lib/metadata/builder.go @@ -83,10 +83,10 @@ func (t *TypeDefinition) WithId(id uint32) *TypeDefinition { func (t *TypeDefinition) WithField(name string, typ string, docs ...*Docs) *TypeDefinition { f := &Field{Name: name, Type: typ} - t.Fields = append(t.Fields, f) if len(docs) > 0 && docs[0] != nil { - t.Docs = docs[0] + f.Docs = docs[0] } + t.Fields = append(t.Fields, f) return t } diff --git a/runtime/graphql/schemagen/schemagen_as_test.go b/runtime/graphql/schemagen/schemagen_as_test.go index 151df4a73..0b01f55e4 100644 --- a/runtime/graphql/schemagen/schemagen_as_test.go +++ b/runtime/graphql/schemagen/schemagen_as_test.go @@ -229,9 +229,15 @@ Each field corresponds to a specific part of the address. The location field stores geospatial coordinates. """ input AddressInput { + """ + Street that the user lives on + """ street: String! city: String! state: String! + """ + Country that the user is from + """ country: String! postalCode: String! location: CoordinatesInput! @@ -276,9 +282,15 @@ Each field corresponds to a specific part of the address. The location field stores geospatial coordinates. """ type Address { + """ + Street that the user lives on + """ street: String! city: String! state: String! + """ + Country that the user is from + """ country: String! postalCode: String! location: Coordinates! diff --git a/runtime/graphql/schemagen/schemagen_go_test.go b/runtime/graphql/schemagen/schemagen_go_test.go index e1df01832..835c47f97 100644 --- a/runtime/graphql/schemagen/schemagen_go_test.go +++ b/runtime/graphql/schemagen/schemagen_go_test.go @@ -263,9 +263,15 @@ Each field corresponds to a specific part of the address. The location field stores geospatial coordinates. """ input AddressInput { + """ + Street that the user lives on + """ street: String! city: String! state: String! + """ + Country that the user is from + """ country: String! postalCode: String! location: CoordinatesInput! @@ -310,9 +316,15 @@ Each field corresponds to a specific part of the address. The location field stores geospatial coordinates. """ type Address { + """ + Street that the user lives on + """ street: String! city: String! state: String! + """ + Country that the user is from + """ country: String! postalCode: String! location: Coordinates!