diff --git a/example/generated.go b/example/generated.go index a287c78..85c4e02 100644 --- a/example/generated.go +++ b/example/generated.go @@ -15,6 +15,9 @@ type getUserResponse struct { User getUserUser `json:"user"` } +// getUserUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A user is an individual's account on GitHub that owns repositories and can make new content. type getUserUser struct { // The user's public profile name. @@ -29,6 +32,9 @@ type getViewerResponse struct { Viewer getViewerViewerUser `json:"viewer"` } +// getViewerViewerUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A user is an individual's account on GitHub that owns repositories and can make new content. type getViewerViewerUser struct { // The user's public profile name. diff --git a/generate/testdata/queries/InputEnum.graphql.go b/generate/testdata/queries/InputEnum.graphql.go index fb6d6d8..eb3cbfc 100644 --- a/generate/testdata/queries/InputEnum.graphql.go +++ b/generate/testdata/queries/InputEnum.graphql.go @@ -13,6 +13,9 @@ type InputEnumQueryResponse struct { UsersWithRole []InputEnumQueryUsersWithRoleUser `json:"usersWithRole"` } +// InputEnumQueryUsersWithRoleUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type InputEnumQueryUsersWithRoleUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/InputObject.graphql.go b/generate/testdata/queries/InputObject.graphql.go index 8ca67d3..523fa16 100644 --- a/generate/testdata/queries/InputObject.graphql.go +++ b/generate/testdata/queries/InputObject.graphql.go @@ -16,6 +16,9 @@ type InputObjectQueryResponse struct { User InputObjectQueryUser `json:"user"` } +// InputObjectQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type InputObjectQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/InterfaceNesting.graphql.go b/generate/testdata/queries/InterfaceNesting.graphql.go index f5fd0e1..913a681 100644 --- a/generate/testdata/queries/InterfaceNesting.graphql.go +++ b/generate/testdata/queries/InterfaceNesting.graphql.go @@ -14,6 +14,7 @@ type InterfaceNestingResponse struct { Root InterfaceNestingRootTopic `json:"root"` } +// InterfaceNestingRootTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopic struct { // ID is documented in the Content interface. Id mypkg.ID `json:"id"` @@ -67,6 +68,7 @@ func (v *InterfaceNestingRootTopic) UnmarshalJSON(b []byte) error { return nil } +// InterfaceNestingRootTopicChildrenArticle includes the requested fields of the GraphQL type Article. type InterfaceNestingRootTopicChildrenArticle struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -76,6 +78,7 @@ type InterfaceNestingRootTopicChildrenArticle struct { func (v InterfaceNestingRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenArticleParentTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenArticleParentTopic struct { // ID is documented in the Content interface. Id mypkg.ID `json:"id"` @@ -129,6 +132,7 @@ func (v *InterfaceNestingRootTopicChildrenArticleParentTopic) UnmarshalJSON(b [] return nil } +// InterfaceNestingRootTopicChildrenArticleParentTopicChildrenArticle includes the requested fields of the GraphQL type Article. type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenArticle struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -137,11 +141,15 @@ type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenArticle struct { func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent includes the requested fields of the GraphQL type Content. +// The GraphQL type's documentation follows. +// // Content is implemented by various types like Article, Video, and Topic. type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent interface { implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() } +// InterfaceNestingRootTopicChildrenArticleParentTopicChildrenTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenTopic struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -150,6 +158,7 @@ type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenTopic struct { func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenArticleParentTopicChildrenVideo includes the requested fields of the GraphQL type Video. type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenVideo struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -158,11 +167,15 @@ type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenVideo struct { func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenContent includes the requested fields of the GraphQL type Content. +// The GraphQL type's documentation follows. +// // Content is implemented by various types like Article, Video, and Topic. type InterfaceNestingRootTopicChildrenContent interface { implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() } +// InterfaceNestingRootTopicChildrenTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenTopic struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -172,6 +185,7 @@ type InterfaceNestingRootTopicChildrenTopic struct { func (v InterfaceNestingRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenTopicParentTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenTopicParentTopic struct { // ID is documented in the Content interface. Id mypkg.ID `json:"id"` @@ -225,6 +239,7 @@ func (v *InterfaceNestingRootTopicChildrenTopicParentTopic) UnmarshalJSON(b []by return nil } +// InterfaceNestingRootTopicChildrenTopicParentTopicChildrenArticle includes the requested fields of the GraphQL type Article. type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenArticle struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -233,11 +248,15 @@ type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenArticle struct { func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent includes the requested fields of the GraphQL type Content. +// The GraphQL type's documentation follows. +// // Content is implemented by various types like Article, Video, and Topic. type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent interface { implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() } +// InterfaceNestingRootTopicChildrenTopicParentTopicChildrenTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenTopic struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -246,6 +265,7 @@ type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenTopic struct { func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenTopicParentTopicChildrenVideo includes the requested fields of the GraphQL type Video. type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenVideo struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -254,6 +274,7 @@ type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenVideo struct { func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenVideo includes the requested fields of the GraphQL type Video. type InterfaceNestingRootTopicChildrenVideo struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -263,6 +284,7 @@ type InterfaceNestingRootTopicChildrenVideo struct { func (v InterfaceNestingRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenVideoParentTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenVideoParentTopic struct { // ID is documented in the Content interface. Id mypkg.ID `json:"id"` @@ -316,6 +338,7 @@ func (v *InterfaceNestingRootTopicChildrenVideoParentTopic) UnmarshalJSON(b []by return nil } +// InterfaceNestingRootTopicChildrenVideoParentTopicChildrenArticle includes the requested fields of the GraphQL type Article. type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenArticle struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -324,11 +347,15 @@ type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenArticle struct { func (v InterfaceNestingRootTopicChildrenVideoParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent includes the requested fields of the GraphQL type Content. +// The GraphQL type's documentation follows. +// // Content is implemented by various types like Article, Video, and Topic. type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent interface { implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent() } +// InterfaceNestingRootTopicChildrenVideoParentTopicChildrenTopic includes the requested fields of the GraphQL type Topic. type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenTopic struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -337,6 +364,7 @@ type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenTopic struct { func (v InterfaceNestingRootTopicChildrenVideoParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent() { } +// InterfaceNestingRootTopicChildrenVideoParentTopicChildrenVideo includes the requested fields of the GraphQL type Video. type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenVideo struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` diff --git a/generate/testdata/queries/InterfaceNoFragments.graphql.go b/generate/testdata/queries/InterfaceNoFragments.graphql.go index 245f668..cb30d83 100644 --- a/generate/testdata/queries/InterfaceNoFragments.graphql.go +++ b/generate/testdata/queries/InterfaceNoFragments.graphql.go @@ -14,6 +14,7 @@ type InterfaceNoFragmentsQueryResponse struct { Root InterfaceNoFragmentsQueryRootTopic `json:"root"` } +// InterfaceNoFragmentsQueryRootTopic includes the requested fields of the GraphQL type Topic. type InterfaceNoFragmentsQueryRootTopic struct { // ID is documented in the Content interface. Id mypkg.ID `json:"id"` @@ -68,6 +69,7 @@ func (v *InterfaceNoFragmentsQueryRootTopic) UnmarshalJSON(b []byte) error { return nil } +// InterfaceNoFragmentsQueryRootTopicChildrenArticle includes the requested fields of the GraphQL type Article. type InterfaceNoFragmentsQueryRootTopicChildrenArticle struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -77,11 +79,15 @@ type InterfaceNoFragmentsQueryRootTopicChildrenArticle struct { func (v InterfaceNoFragmentsQueryRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() { } +// InterfaceNoFragmentsQueryRootTopicChildrenContent includes the requested fields of the GraphQL type Content. +// The GraphQL type's documentation follows. +// // Content is implemented by various types like Article, Video, and Topic. type InterfaceNoFragmentsQueryRootTopicChildrenContent interface { implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() } +// InterfaceNoFragmentsQueryRootTopicChildrenTopic includes the requested fields of the GraphQL type Topic. type InterfaceNoFragmentsQueryRootTopicChildrenTopic struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` @@ -91,6 +97,7 @@ type InterfaceNoFragmentsQueryRootTopicChildrenTopic struct { func (v InterfaceNoFragmentsQueryRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() { } +// InterfaceNoFragmentsQueryRootTopicChildrenVideo includes the requested fields of the GraphQL type Video. type InterfaceNoFragmentsQueryRootTopicChildrenVideo struct { // ID is the identifier of the content. Id mypkg.ID `json:"id"` diff --git a/generate/testdata/queries/ListInput.graphql.go b/generate/testdata/queries/ListInput.graphql.go index 517b217..32571c9 100644 --- a/generate/testdata/queries/ListInput.graphql.go +++ b/generate/testdata/queries/ListInput.graphql.go @@ -16,6 +16,9 @@ type ListInputQueryResponse struct { User ListInputQueryUser `json:"user"` } +// ListInputQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type ListInputQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/Omitempty.graphql.go b/generate/testdata/queries/Omitempty.graphql.go index fc5b900..d957428 100644 --- a/generate/testdata/queries/Omitempty.graphql.go +++ b/generate/testdata/queries/Omitempty.graphql.go @@ -20,6 +20,9 @@ type OmitEmptyQueryResponse struct { Convert2 time.Time `json:"convert2"` } +// OmitEmptyQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type OmitEmptyQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/Pointers.graphql.go b/generate/testdata/queries/Pointers.graphql.go index c716cb5..abd9023 100644 --- a/generate/testdata/queries/Pointers.graphql.go +++ b/generate/testdata/queries/Pointers.graphql.go @@ -9,6 +9,9 @@ import ( "github.com/me/mypkg" ) +// PointersQueryOtherUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type PointersQueryOtherUser struct { // id is the user's ID. @@ -32,6 +35,9 @@ type PointersQueryResponse struct { MaybeConvert *time.Time `json:"maybeConvert"` } +// PointersQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type PointersQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/PointersInline.graphql.go b/generate/testdata/queries/PointersInline.graphql.go index 8696432..5c0e04d 100644 --- a/generate/testdata/queries/PointersInline.graphql.go +++ b/generate/testdata/queries/PointersInline.graphql.go @@ -9,6 +9,9 @@ import ( "github.com/me/mypkg" ) +// PointersQueryOtherUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type PointersQueryOtherUser struct { // id is the user's ID. @@ -32,6 +35,9 @@ type PointersQueryResponse struct { MaybeConvert time.Time `json:"maybeConvert"` } +// PointersQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type PointersQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/QueryWithAlias.graphql.go b/generate/testdata/queries/QueryWithAlias.graphql.go index e5af030..5ed7df0 100644 --- a/generate/testdata/queries/QueryWithAlias.graphql.go +++ b/generate/testdata/queries/QueryWithAlias.graphql.go @@ -16,6 +16,9 @@ type QueryWithAliasResponse struct { User QueryWithAliasUser `json:"User"` } +// QueryWithAliasUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type QueryWithAliasUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/QueryWithDoubleAlias.graphql.go b/generate/testdata/queries/QueryWithDoubleAlias.graphql.go index 5e98721..7904076 100644 --- a/generate/testdata/queries/QueryWithDoubleAlias.graphql.go +++ b/generate/testdata/queries/QueryWithDoubleAlias.graphql.go @@ -16,6 +16,9 @@ type QueryWithDoubleAliasResponse struct { User QueryWithDoubleAliasUser `json:"user"` } +// QueryWithDoubleAliasUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type QueryWithDoubleAliasUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/QueryWithEnums.graphql.go b/generate/testdata/queries/QueryWithEnums.graphql.go index 7ff1c74..7c373f2 100644 --- a/generate/testdata/queries/QueryWithEnums.graphql.go +++ b/generate/testdata/queries/QueryWithEnums.graphql.go @@ -6,6 +6,9 @@ import ( "github.com/Khan/genqlient/graphql" ) +// QueryWithEnumsOtherUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type QueryWithEnumsOtherUser struct { Roles []Role `json:"roles"` @@ -25,6 +28,9 @@ type QueryWithEnumsResponse struct { OtherUser QueryWithEnumsOtherUser `json:"otherUser"` } +// QueryWithEnumsUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type QueryWithEnumsUser struct { Roles []Role `json:"roles"` diff --git a/generate/testdata/queries/QueryWithSlices.graphql.go b/generate/testdata/queries/QueryWithSlices.graphql.go index bb729f5..6a53625 100644 --- a/generate/testdata/queries/QueryWithSlices.graphql.go +++ b/generate/testdata/queries/QueryWithSlices.graphql.go @@ -15,6 +15,9 @@ type QueryWithSlicesResponse struct { User QueryWithSlicesUser `json:"user"` } +// QueryWithSlicesUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type QueryWithSlicesUser struct { Emails []string `json:"emails"` diff --git a/generate/testdata/queries/QueryWithStructs.graphql.go b/generate/testdata/queries/QueryWithStructs.graphql.go index 946727b..a58824a 100644 --- a/generate/testdata/queries/QueryWithStructs.graphql.go +++ b/generate/testdata/queries/QueryWithStructs.graphql.go @@ -15,11 +15,15 @@ type QueryWithStructsResponse struct { User QueryWithStructsUser `json:"user"` } +// QueryWithStructsUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type QueryWithStructsUser struct { AuthMethods []QueryWithStructsUserAuthMethodsAuthMethod `json:"authMethods"` } +// QueryWithStructsUserAuthMethodsAuthMethod includes the requested fields of the GraphQL type AuthMethod. type QueryWithStructsUserAuthMethodsAuthMethod struct { Provider string `json:"provider"` Email string `json:"email"` diff --git a/generate/testdata/queries/SimpleInput.graphql.go b/generate/testdata/queries/SimpleInput.graphql.go index a01b42a..11837d7 100644 --- a/generate/testdata/queries/SimpleInput.graphql.go +++ b/generate/testdata/queries/SimpleInput.graphql.go @@ -16,6 +16,9 @@ type SimpleInputQueryResponse struct { User SimpleInputQueryUser `json:"user"` } +// SimpleInputQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type SimpleInputQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/SimpleMutation.graphql.go b/generate/testdata/queries/SimpleMutation.graphql.go index 6a22491..50836e7 100644 --- a/generate/testdata/queries/SimpleMutation.graphql.go +++ b/generate/testdata/queries/SimpleMutation.graphql.go @@ -7,6 +7,9 @@ import ( "github.com/me/mypkg" ) +// SimpleMutationCreateUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type SimpleMutationCreateUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/SimpleQuery.graphql.go b/generate/testdata/queries/SimpleQuery.graphql.go index 59e6d82..bcfafec 100644 --- a/generate/testdata/queries/SimpleQuery.graphql.go +++ b/generate/testdata/queries/SimpleQuery.graphql.go @@ -16,6 +16,9 @@ type SimpleQueryResponse struct { User SimpleQueryUser `json:"user"` } +// SimpleQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type SimpleQueryUser struct { // id is the user's ID. diff --git a/generate/testdata/queries/TypeName.graphql.go b/generate/testdata/queries/TypeName.graphql.go index 5d8f945..044462a 100644 --- a/generate/testdata/queries/TypeName.graphql.go +++ b/generate/testdata/queries/TypeName.graphql.go @@ -16,6 +16,9 @@ type TypeNameQueryResponse struct { User TypeNameQueryUser `json:"user"` } +// TypeNameQueryUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type TypeNameQueryUser struct { Typename string `json:"__typename"` diff --git a/generate/testdata/queries/UnionNoFragments.graphql.go b/generate/testdata/queries/UnionNoFragments.graphql.go index 7140826..d8e934d 100644 --- a/generate/testdata/queries/UnionNoFragments.graphql.go +++ b/generate/testdata/queries/UnionNoFragments.graphql.go @@ -8,6 +8,7 @@ import ( "github.com/Khan/genqlient/graphql" ) +// UnionNoFragmentsQueryRandomLeafArticle includes the requested fields of the GraphQL type Article. type UnionNoFragmentsQueryRandomLeafArticle struct { Typename string `json:"__typename"` } @@ -15,11 +16,15 @@ type UnionNoFragmentsQueryRandomLeafArticle struct { func (v UnionNoFragmentsQueryRandomLeafArticle) implementsGraphQLInterfaceUnionNoFragmentsQueryRandomLeafLeafContent() { } +// UnionNoFragmentsQueryRandomLeafLeafContent includes the requested fields of the GraphQL type LeafContent. +// The GraphQL type's documentation follows. +// // LeafContent represents content items that can't have child-nodes. type UnionNoFragmentsQueryRandomLeafLeafContent interface { implementsGraphQLInterfaceUnionNoFragmentsQueryRandomLeafLeafContent() } +// UnionNoFragmentsQueryRandomLeafVideo includes the requested fields of the GraphQL type Video. type UnionNoFragmentsQueryRandomLeafVideo struct { Typename string `json:"__typename"` } diff --git a/generate/testdata/queries/UsesEnumTwice.graphql.go b/generate/testdata/queries/UsesEnumTwice.graphql.go index d19675b..a2310e8 100644 --- a/generate/testdata/queries/UsesEnumTwice.graphql.go +++ b/generate/testdata/queries/UsesEnumTwice.graphql.go @@ -20,11 +20,17 @@ const ( RoleTeacher Role = "TEACHER" ) +// UsesEnumTwiceQueryMeUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type UsesEnumTwiceQueryMeUser struct { Roles []Role `json:"roles"` } +// UsesEnumTwiceQueryOtherUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type UsesEnumTwiceQueryOtherUser struct { Roles []Role `json:"roles"` diff --git a/generate/testdata/queries/unexported.graphql.go b/generate/testdata/queries/unexported.graphql.go index aca5447..878c181 100644 --- a/generate/testdata/queries/unexported.graphql.go +++ b/generate/testdata/queries/unexported.graphql.go @@ -30,6 +30,9 @@ type unexportedResponse struct { User unexportedUser `json:"user"` } +// unexportedUser includes the requested fields of the GraphQL type User. +// The GraphQL type's documentation follows. +// // A User is a user! type unexportedUser struct { // id is the user's ID. diff --git a/generate/types.go b/generate/types.go index e1248e5..90a04c3 100644 --- a/generate/types.go +++ b/generate/types.go @@ -317,7 +317,25 @@ func (builder *typeBuilder) writeTypedef( }() if description == "" { - description = typedef.Description + switch typedef.Kind { + case ast.Object, ast.Interface, ast.Union: + // For types where we only have some fields, note that, along with + // the GraphQL documentation (if any). We don't want to just use + // the GraphQL documentation, since it may refer to fields we + // haven't selected, say. + // TODO: When we implement interfaces and unions more completely, + // also mention the concrete types they might be. + description = fmt.Sprintf( + "%v includes the requested fields of the GraphQL type %v.", + typeName, typedef.Name) + if typedef.Description != "" { + description = fmt.Sprintf( + "%v\nThe GraphQL type's documentation follows.\n\n%v", + description, typedef.Description) + } + default: + description = typedef.Description + } } builder.writeDescription(description)