Add support for abstract-typed named fragments (#79)

## Summary:
In previous commits I added support to genqlient for interfaces,
inline fragments, and, most recently, named fragments of concrete
(object) type.  This leaves only named fragments of interface type!
Like other named fragments, these are useful for code-sharing,
especially if you want some code that can handle the same fields of
several different types.

As seems to be inevitable with genqlient, this was mostly pretty
straightforward, although there turned out to be surprisingly many
places we needed to add some handling; almost anywhere that touches
interfaces *or* named fragments needed some updates.  But it's all
hopefully fairly clear code.

As a part of this change I made three semi-related improvements:
1. I refactored the handling of descriptions (i.e. GoDoc), because it
   was getting more and more confusing and duplicative.  I'm still not
   sure how much of it it makes sense to inline vs. separate, but I
   think this is better than it was.  This resulted in some minor
   changes to descriptions, generally in the direction of making things
   more consistent.
2. I bumped the minimum Go version to 1.14 so we can guarantee support
   for duplicate interface methods.  These are useful for
   abstract-in-absstract spreads; we generate an interface for the
   fragment, and (if the fragment-type implements the scope-type) we
   embed it into the interface we generate for its spread-context, and
   if the two have a duplicated field we thus duplicate the method.  It
   wouldn't be impossible to support this on 1.13 (maybe just by
   omitting said embed) but it didn't seem worth it.  This also removes
   a few special-cases in tests.
3. I added a bunch of code to better format syntax errors in the
   generated code (which we see from `gofmt`).  This is mostly just an
   internal improvement; I wrote it because I got annoyed while hunting
   down a few such errors..

Fixes, at last, #8.

Issue: https://github.com/Khan/genqlient/issues/8

## Test plan:
make check


Author: benjaminjkraft

Reviewers: dnerdy, benjaminjkraft, aberkan, MiguelCastillo

Required Reviewers: 

Approved By: dnerdy

Checks:  Lint,  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Lint

Pull Request URL: https://github.com/Khan/genqlient/pull/79
This commit is contained in:
Ben Kraft
2021-09-09 09:48:18 -07:00
committed by GitHub
parent f99c10d6fd
commit e88305ecbd
22 changed files with 704 additions and 228 deletions
+10
View File
@@ -6,20 +6,25 @@ fragment InnerQueryFragment on Query {
randomItem {
id name
...VideoFields
...ContentFields
}
randomLeaf {
...VideoFields
...MoreVideoFields
...ContentFields
}
otherLeaf: randomLeaf {
... on Video {
...MoreVideoFields
...ContentFields
}
...ContentFields
}
}
fragment VideoFields on Video {
id name url duration thumbnail { id }
...ContentFields
}
# @genqlient(pointer: true)
@@ -27,6 +32,7 @@ fragment MoreVideoFields on Video {
id
parent {
name url
...ContentFields
# @genqlient(pointer: false)
children {
...VideoFields
@@ -34,6 +40,10 @@ fragment MoreVideoFields on Video {
}
}
fragment ContentFields on Content {
name url
}
query ComplexNamedFragments {
... on Query { ...QueryFragment }
}
@@ -28,7 +28,6 @@ type ComplexInlineFragmentsConflictingStuffArticleThumbnailStuffThumbnail struct
// ComplexInlineFragmentsConflictingStuffArticle
// ComplexInlineFragmentsConflictingStuffVideo
// ComplexInlineFragmentsConflictingStuffTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -116,7 +115,6 @@ type ComplexInlineFragmentsNestedStuffArticle struct {
// ComplexInlineFragmentsNestedStuffArticle
// ComplexInlineFragmentsNestedStuffVideo
// ComplexInlineFragmentsNestedStuffTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -212,7 +210,6 @@ func (v *ComplexInlineFragmentsNestedStuffTopic) UnmarshalJSON(b []byte) error {
}
}
}
return nil
}
@@ -260,7 +257,6 @@ func (v *ComplexInlineFragmentsNestedStuffTopicChildrenArticleParentContentParen
}
}
}
return nil
}
@@ -278,7 +274,6 @@ type ComplexInlineFragmentsNestedStuffTopicChildrenArticleParentContentParentTop
// ComplexInlineFragmentsNestedStuffTopicChildrenArticleParentContentParentTopicChildrenArticle
// ComplexInlineFragmentsNestedStuffTopicChildrenArticleParentContentParentTopicChildrenVideo
// ComplexInlineFragmentsNestedStuffTopicChildrenArticleParentContentParentTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -409,7 +404,6 @@ type ComplexInlineFragmentsNestedStuffTopicChildrenArticleParentTopic struct {
// ComplexInlineFragmentsNestedStuffTopicChildrenArticle
// ComplexInlineFragmentsNestedStuffTopicChildrenVideo
// ComplexInlineFragmentsNestedStuffTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -519,7 +513,6 @@ type ComplexInlineFragmentsRandomItemArticle struct {
// ComplexInlineFragmentsRandomItemArticle
// ComplexInlineFragmentsRandomItemVideo
// ComplexInlineFragmentsRandomItemTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -640,7 +633,6 @@ type ComplexInlineFragmentsRepeatedStuffArticle struct {
// ComplexInlineFragmentsRepeatedStuffArticle
// ComplexInlineFragmentsRepeatedStuffVideo
// ComplexInlineFragmentsRepeatedStuffTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -855,7 +847,6 @@ func (v *ComplexInlineFragmentsResponse) UnmarshalJSON(b []byte) error {
"Unable to unmarshal ComplexInlineFragmentsResponse.NestedStuff: %w", err)
}
}
return nil
}
@@ -28,14 +28,118 @@ func (v *ComplexNamedFragmentsResponse) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.QueryFragment)
err = json.Unmarshal(
b, &v.QueryFragment)
if err != nil {
return err
}
return nil
}
// ContentFields includes the GraphQL fields of Content requested by the fragment ContentFields.
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
//
// ContentFields is implemented by the following types:
// ContentFieldsArticle
// ContentFieldsVideo
// ContentFieldsTopic
type ContentFields interface {
implementsGraphQLInterfaceContentFields()
// GetName returns the interface-field "name" from its implementation.
GetName() string
// GetUrl returns the interface-field "url" from its implementation.
GetUrl() string
}
func (v *ContentFieldsArticle) implementsGraphQLInterfaceContentFields() {}
// GetName is a part of, and documented with, the interface ContentFields.
func (v *ContentFieldsArticle) GetName() string { return v.Name }
// GetUrl is a part of, and documented with, the interface ContentFields.
func (v *ContentFieldsArticle) GetUrl() string { return v.Url }
func (v *ContentFieldsVideo) implementsGraphQLInterfaceContentFields() {}
// GetName is a part of, and documented with, the interface ContentFields.
func (v *ContentFieldsVideo) GetName() string { return v.Name }
// GetUrl is a part of, and documented with, the interface ContentFields.
func (v *ContentFieldsVideo) GetUrl() string { return v.Url }
func (v *ContentFieldsTopic) implementsGraphQLInterfaceContentFields() {}
// GetName is a part of, and documented with, the interface ContentFields.
func (v *ContentFieldsTopic) GetName() string { return v.Name }
// GetUrl is a part of, and documented with, the interface ContentFields.
func (v *ContentFieldsTopic) GetUrl() string { return v.Url }
func __unmarshalContentFields(v *ContentFields, m json.RawMessage) error {
if string(m) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(m, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "Article":
*v = new(ContentFieldsArticle)
return json.Unmarshal(m, *v)
case "Video":
*v = new(ContentFieldsVideo)
return json.Unmarshal(m, *v)
case "Topic":
*v = new(ContentFieldsTopic)
return json.Unmarshal(m, *v)
case "":
return fmt.Errorf(
"Response was missing Content.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for ContentFields: "%v"`, tn.TypeName)
}
}
// ContentFields includes the GraphQL fields of Article requested by the fragment ContentFields.
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
type ContentFieldsArticle struct {
Name string `json:"name"`
Url string `json:"url"`
}
// ContentFields includes the GraphQL fields of Topic requested by the fragment ContentFields.
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
type ContentFieldsTopic struct {
Name string `json:"name"`
Url string `json:"url"`
}
// ContentFields includes the GraphQL fields of Video requested by the fragment ContentFields.
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
type ContentFieldsVideo struct {
Name string `json:"name"`
Url string `json:"url"`
}
// InnerQueryFragment includes the GraphQL fields of Query requested by the fragment InnerQueryFragment.
// The GraphQL type's documentation follows.
//
// Query's description is probably ignored by almost all callers.
type InnerQueryFragment struct {
RandomItem InnerQueryFragmentRandomItemContent `json:"-"`
RandomLeaf InnerQueryFragmentRandomLeafLeafContent `json:"-"`
@@ -90,13 +194,34 @@ func (v *InnerQueryFragment) UnmarshalJSON(b []byte) error {
"Unable to unmarshal InnerQueryFragment.OtherLeaf: %w", err)
}
}
return nil
}
// InnerQueryFragmentOtherLeafArticle includes the requested fields of the GraphQL type Article.
type InnerQueryFragmentOtherLeafArticle struct {
Typename string `json:"__typename"`
Typename string `json:"__typename"`
ContentFieldsArticle `json:"-"`
}
func (v *InnerQueryFragmentOtherLeafArticle) UnmarshalJSON(b []byte) error {
var firstPass struct {
*InnerQueryFragmentOtherLeafArticle
graphql.NoUnmarshalJSON
}
firstPass.InnerQueryFragmentOtherLeafArticle = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsArticle)
if err != nil {
return err
}
return nil
}
// InnerQueryFragmentOtherLeafLeafContent includes the requested fields of the GraphQL interface LeafContent.
@@ -104,7 +229,6 @@ type InnerQueryFragmentOtherLeafArticle struct {
// InnerQueryFragmentOtherLeafLeafContent is implemented by the following types:
// InnerQueryFragmentOtherLeafArticle
// InnerQueryFragmentOtherLeafVideo
//
// The GraphQL type's documentation follows.
//
// LeafContent represents content items that can't have child-nodes.
@@ -157,8 +281,9 @@ func __unmarshalInnerQueryFragmentOtherLeafLeafContent(v *InnerQueryFragmentOthe
// InnerQueryFragmentOtherLeafVideo includes the requested fields of the GraphQL type Video.
type InnerQueryFragmentOtherLeafVideo struct {
Typename string `json:"__typename"`
MoreVideoFields `json:"-"`
Typename string `json:"__typename"`
MoreVideoFields `json:"-"`
ContentFieldsVideo `json:"-"`
}
func (v *InnerQueryFragmentOtherLeafVideo) UnmarshalJSON(b []byte) error {
@@ -174,7 +299,13 @@ func (v *InnerQueryFragmentOtherLeafVideo) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.MoreVideoFields)
err = json.Unmarshal(
b, &v.MoreVideoFields)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsVideo)
if err != nil {
return err
}
@@ -185,8 +316,30 @@ func (v *InnerQueryFragmentOtherLeafVideo) UnmarshalJSON(b []byte) error {
type InnerQueryFragmentRandomItemArticle struct {
Typename string `json:"__typename"`
// ID is the identifier of the content.
Id testutil.ID `json:"id"`
Name string `json:"name"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
ContentFieldsArticle `json:"-"`
}
func (v *InnerQueryFragmentRandomItemArticle) UnmarshalJSON(b []byte) error {
var firstPass struct {
*InnerQueryFragmentRandomItemArticle
graphql.NoUnmarshalJSON
}
firstPass.InnerQueryFragmentRandomItemArticle = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsArticle)
if err != nil {
return err
}
return nil
}
// InnerQueryFragmentRandomItemContent includes the requested fields of the GraphQL interface Content.
@@ -195,7 +348,6 @@ type InnerQueryFragmentRandomItemArticle struct {
// InnerQueryFragmentRandomItemArticle
// InnerQueryFragmentRandomItemVideo
// InnerQueryFragmentRandomItemTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -210,6 +362,7 @@ type InnerQueryFragmentRandomItemContent interface {
GetId() testutil.ID
// GetName returns the interface-field "name" from its implementation.
GetName() string
ContentFields
}
func (v *InnerQueryFragmentRandomItemArticle) implementsGraphQLInterfaceInnerQueryFragmentRandomItemContent() {
@@ -284,17 +437,40 @@ func __unmarshalInnerQueryFragmentRandomItemContent(v *InnerQueryFragmentRandomI
type InnerQueryFragmentRandomItemTopic struct {
Typename string `json:"__typename"`
// ID is the identifier of the content.
Id testutil.ID `json:"id"`
Name string `json:"name"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
ContentFieldsTopic `json:"-"`
}
func (v *InnerQueryFragmentRandomItemTopic) UnmarshalJSON(b []byte) error {
var firstPass struct {
*InnerQueryFragmentRandomItemTopic
graphql.NoUnmarshalJSON
}
firstPass.InnerQueryFragmentRandomItemTopic = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsTopic)
if err != nil {
return err
}
return nil
}
// InnerQueryFragmentRandomItemVideo includes the requested fields of the GraphQL type Video.
type InnerQueryFragmentRandomItemVideo struct {
Typename string `json:"__typename"`
// ID is the identifier of the content.
Id testutil.ID `json:"id"`
Name string `json:"name"`
VideoFields `json:"-"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
VideoFields `json:"-"`
ContentFieldsVideo `json:"-"`
}
func (v *InnerQueryFragmentRandomItemVideo) UnmarshalJSON(b []byte) error {
@@ -310,7 +486,13 @@ func (v *InnerQueryFragmentRandomItemVideo) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.VideoFields)
err = json.Unmarshal(
b, &v.VideoFields)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsVideo)
if err != nil {
return err
}
@@ -319,7 +501,29 @@ func (v *InnerQueryFragmentRandomItemVideo) UnmarshalJSON(b []byte) error {
// InnerQueryFragmentRandomLeafArticle includes the requested fields of the GraphQL type Article.
type InnerQueryFragmentRandomLeafArticle struct {
Typename string `json:"__typename"`
Typename string `json:"__typename"`
ContentFieldsArticle `json:"-"`
}
func (v *InnerQueryFragmentRandomLeafArticle) UnmarshalJSON(b []byte) error {
var firstPass struct {
*InnerQueryFragmentRandomLeafArticle
graphql.NoUnmarshalJSON
}
firstPass.InnerQueryFragmentRandomLeafArticle = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsArticle)
if err != nil {
return err
}
return nil
}
// InnerQueryFragmentRandomLeafLeafContent includes the requested fields of the GraphQL interface LeafContent.
@@ -327,7 +531,6 @@ type InnerQueryFragmentRandomLeafArticle struct {
// InnerQueryFragmentRandomLeafLeafContent is implemented by the following types:
// InnerQueryFragmentRandomLeafArticle
// InnerQueryFragmentRandomLeafVideo
//
// The GraphQL type's documentation follows.
//
// LeafContent represents content items that can't have child-nodes.
@@ -380,9 +583,10 @@ func __unmarshalInnerQueryFragmentRandomLeafLeafContent(v *InnerQueryFragmentRan
// InnerQueryFragmentRandomLeafVideo includes the requested fields of the GraphQL type Video.
type InnerQueryFragmentRandomLeafVideo struct {
Typename string `json:"__typename"`
VideoFields `json:"-"`
MoreVideoFields `json:"-"`
Typename string `json:"__typename"`
VideoFields `json:"-"`
MoreVideoFields `json:"-"`
ContentFieldsVideo `json:"-"`
}
func (v *InnerQueryFragmentRandomLeafVideo) UnmarshalJSON(b []byte) error {
@@ -398,12 +602,18 @@ func (v *InnerQueryFragmentRandomLeafVideo) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.VideoFields)
err = json.Unmarshal(
b, &v.VideoFields)
if err != nil {
return err
}
err = json.Unmarshal(b, &v.MoreVideoFields)
err = json.Unmarshal(
b, &v.MoreVideoFields)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsVideo)
if err != nil {
return err
}
@@ -419,9 +629,10 @@ type MoreVideoFields struct {
// MoreVideoFieldsParentTopic includes the requested fields of the GraphQL type Topic.
type MoreVideoFieldsParentTopic struct {
Name *string `json:"name"`
Url *string `json:"url"`
Children []MoreVideoFieldsParentTopicChildrenContent `json:"-"`
Name *string `json:"name"`
Url *string `json:"url"`
ContentFieldsTopic `json:"-"`
Children []MoreVideoFieldsParentTopicChildrenContent `json:"-"`
}
func (v *MoreVideoFieldsParentTopic) UnmarshalJSON(b []byte) error {
@@ -438,6 +649,12 @@ func (v *MoreVideoFieldsParentTopic) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsTopic)
if err != nil {
return err
}
{
target := &v.Children
raw := firstPass.Children
@@ -454,7 +671,6 @@ func (v *MoreVideoFieldsParentTopic) UnmarshalJSON(b []byte) error {
}
}
}
return nil
}
@@ -469,7 +685,6 @@ type MoreVideoFieldsParentTopicChildrenArticle struct {
// MoreVideoFieldsParentTopicChildrenArticle
// MoreVideoFieldsParentTopicChildrenVideo
// MoreVideoFieldsParentTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -553,7 +768,8 @@ func (v *MoreVideoFieldsParentTopicChildrenVideo) UnmarshalJSON(b []byte) error
return err
}
err = json.Unmarshal(b, &v.VideoFields)
err = json.Unmarshal(
b, &v.VideoFields)
if err != nil {
return err
}
@@ -561,6 +777,9 @@ func (v *MoreVideoFieldsParentTopicChildrenVideo) UnmarshalJSON(b []byte) error
}
// QueryFragment includes the GraphQL fields of Query requested by the fragment QueryFragment.
// The GraphQL type's documentation follows.
//
// Query's description is probably ignored by almost all callers.
type QueryFragment struct {
InnerQueryFragment `json:"-"`
}
@@ -578,7 +797,8 @@ func (v *QueryFragment) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.InnerQueryFragment)
err = json.Unmarshal(
b, &v.InnerQueryFragment)
if err != nil {
return err
}
@@ -588,11 +808,33 @@ func (v *QueryFragment) UnmarshalJSON(b []byte) error {
// VideoFields includes the GraphQL fields of Video requested by the fragment VideoFields.
type VideoFields struct {
// ID is documented in the Content interface.
Id testutil.ID `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
Duration int `json:"duration"`
Thumbnail VideoFieldsThumbnail `json:"thumbnail"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
Duration int `json:"duration"`
Thumbnail VideoFieldsThumbnail `json:"thumbnail"`
ContentFieldsVideo `json:"-"`
}
func (v *VideoFields) UnmarshalJSON(b []byte) error {
var firstPass struct {
*VideoFields
graphql.NoUnmarshalJSON
}
firstPass.VideoFields = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
err = json.Unmarshal(
b, &v.ContentFieldsVideo)
if err != nil {
return err
}
return nil
}
// VideoFieldsThumbnail includes the requested fields of the GraphQL type Thumbnail.
@@ -624,17 +866,21 @@ fragment InnerQueryFragment on Query {
id
name
... VideoFields
... ContentFields
}
randomLeaf {
__typename
... VideoFields
... MoreVideoFields
... ContentFields
}
otherLeaf: randomLeaf {
__typename
... on Video {
... MoreVideoFields
... ContentFields
}
... ContentFields
}
}
fragment VideoFields on Video {
@@ -645,12 +891,18 @@ fragment VideoFields on Video {
thumbnail {
id
}
... ContentFields
}
fragment ContentFields on Content {
name
url
}
fragment MoreVideoFields on Video {
id
parent {
name
url
... ContentFields
children {
__typename
... VideoFields
@@ -2,7 +2,7 @@
"operations": [
{
"operationName": "ComplexNamedFragments",
"query": "\nquery ComplexNamedFragments {\n\t... on Query {\n\t\t... QueryFragment\n\t}\n}\nfragment QueryFragment on Query {\n\t... InnerQueryFragment\n}\nfragment InnerQueryFragment on Query {\n\trandomItem {\n\t\t__typename\n\t\tid\n\t\tname\n\t\t... VideoFields\n\t}\n\trandomLeaf {\n\t\t__typename\n\t\t... VideoFields\n\t\t... MoreVideoFields\n\t}\n\totherLeaf: randomLeaf {\n\t\t__typename\n\t\t... on Video {\n\t\t\t... MoreVideoFields\n\t\t}\n\t}\n}\nfragment VideoFields on Video {\n\tid\n\tname\n\turl\n\tduration\n\tthumbnail {\n\t\tid\n\t}\n}\nfragment MoreVideoFields on Video {\n\tid\n\tparent {\n\t\tname\n\t\turl\n\t\tchildren {\n\t\t\t__typename\n\t\t\t... VideoFields\n\t\t}\n\t}\n}\n",
"query": "\nquery ComplexNamedFragments {\n\t... on Query {\n\t\t... QueryFragment\n\t}\n}\nfragment QueryFragment on Query {\n\t... InnerQueryFragment\n}\nfragment InnerQueryFragment on Query {\n\trandomItem {\n\t\t__typename\n\t\tid\n\t\tname\n\t\t... VideoFields\n\t\t... ContentFields\n\t}\n\trandomLeaf {\n\t\t__typename\n\t\t... VideoFields\n\t\t... MoreVideoFields\n\t\t... ContentFields\n\t}\n\totherLeaf: randomLeaf {\n\t\t__typename\n\t\t... on Video {\n\t\t\t... MoreVideoFields\n\t\t\t... ContentFields\n\t\t}\n\t\t... ContentFields\n\t}\n}\nfragment VideoFields on Video {\n\tid\n\tname\n\turl\n\tduration\n\tthumbnail {\n\t\tid\n\t}\n\t... ContentFields\n}\nfragment ContentFields on Content {\n\tname\n\turl\n}\nfragment MoreVideoFields on Video {\n\tid\n\tparent {\n\t\tname\n\t\turl\n\t\t... ContentFields\n\t\tchildren {\n\t\t\t__typename\n\t\t\t... VideoFields\n\t\t}\n\t}\n}\n",
"sourceLocation": "testdata/queries/ComplexNamedFragments.graphql"
}
]
@@ -54,7 +54,6 @@ func (v *InterfaceListFieldRootTopic) UnmarshalJSON(b []byte) error {
}
}
}
return nil
}
@@ -72,7 +71,6 @@ type InterfaceListFieldRootTopicChildrenArticle struct {
// InterfaceListFieldRootTopicChildrenArticle
// InterfaceListFieldRootTopicChildrenVideo
// InterfaceListFieldRootTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -211,7 +209,6 @@ func (v *InterfaceListFieldWithPointerTopic) UnmarshalJSON(b []byte) error {
}
}
}
return nil
}
@@ -229,7 +226,6 @@ type InterfaceListFieldWithPointerTopicChildrenArticle struct {
// InterfaceListFieldWithPointerTopicChildrenArticle
// InterfaceListFieldWithPointerTopicChildrenVideo
// InterfaceListFieldWithPointerTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -16,7 +16,6 @@ import (
// InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle
// InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo
// InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -222,7 +221,6 @@ func (v *InterfaceListOfListOfListsFieldResponse) UnmarshalJSON(b []byte) error
}
}
}
return nil
}
@@ -240,7 +238,6 @@ type InterfaceListOfListOfListsFieldWithPointerArticle struct {
// InterfaceListOfListOfListsFieldWithPointerArticle
// InterfaceListOfListOfListsFieldWithPointerVideo
// InterfaceListOfListOfListsFieldWithPointerTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -52,7 +52,6 @@ func (v *InterfaceNestingRootTopic) UnmarshalJSON(b []byte) error {
}
}
}
return nil
}
@@ -70,7 +69,6 @@ type InterfaceNestingRootTopicChildrenArticle struct {
// InterfaceNestingRootTopicChildrenArticle
// InterfaceNestingRootTopicChildrenVideo
// InterfaceNestingRootTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -198,7 +196,6 @@ func (v *InterfaceNestingRootTopicChildrenContentParentTopic) UnmarshalJSON(b []
}
}
}
return nil
}
@@ -215,7 +212,6 @@ type InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle struct {
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -24,7 +24,6 @@ type InterfaceNoFragmentsQueryRandomItemArticle struct {
// InterfaceNoFragmentsQueryRandomItemArticle
// InterfaceNoFragmentsQueryRandomItemVideo
// InterfaceNoFragmentsQueryRandomItemTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -139,7 +138,6 @@ type InterfaceNoFragmentsQueryRandomItemWithTypeNameArticle struct {
// InterfaceNoFragmentsQueryRandomItemWithTypeNameArticle
// InterfaceNoFragmentsQueryRandomItemWithTypeNameVideo
// InterfaceNoFragmentsQueryRandomItemWithTypeNameTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -303,7 +301,6 @@ func (v *InterfaceNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error {
"Unable to unmarshal InterfaceNoFragmentsQueryResponse.WithPointer: %w", err)
}
}
return nil
}
@@ -328,7 +325,6 @@ type InterfaceNoFragmentsQueryWithPointerArticle struct {
// InterfaceNoFragmentsQueryWithPointerArticle
// InterfaceNoFragmentsQueryWithPointerVideo
// InterfaceNoFragmentsQueryWithPointerTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -25,7 +25,6 @@ type SimpleInlineFragmentRandomItemArticle struct {
// SimpleInlineFragmentRandomItemArticle
// SimpleInlineFragmentRandomItemVideo
// SimpleInlineFragmentRandomItemTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -156,7 +155,6 @@ func (v *SimpleInlineFragmentResponse) UnmarshalJSON(b []byte) error {
"Unable to unmarshal SimpleInlineFragmentResponse.RandomItem: %w", err)
}
}
return nil
}
@@ -24,7 +24,6 @@ type SimpleNamedFragmentRandomItemArticle struct {
// SimpleNamedFragmentRandomItemArticle
// SimpleNamedFragmentRandomItemVideo
// SimpleNamedFragmentRandomItemTopic
//
// The GraphQL type's documentation follows.
//
// Content is implemented by various types like Article, Video, and Topic.
@@ -139,7 +138,8 @@ func (v *SimpleNamedFragmentRandomItemVideo) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.VideoFields)
err = json.Unmarshal(
b, &v.VideoFields)
if err != nil {
return err
}
@@ -156,7 +156,6 @@ type SimpleNamedFragmentRandomLeafArticle struct {
// SimpleNamedFragmentRandomLeafLeafContent is implemented by the following types:
// SimpleNamedFragmentRandomLeafArticle
// SimpleNamedFragmentRandomLeafVideo
//
// The GraphQL type's documentation follows.
//
// LeafContent represents content items that can't have child-nodes.
@@ -226,7 +225,8 @@ func (v *SimpleNamedFragmentRandomLeafVideo) UnmarshalJSON(b []byte) error {
return err
}
err = json.Unmarshal(b, &v.VideoFields)
err = json.Unmarshal(
b, &v.VideoFields)
if err != nil {
return err
}
@@ -275,7 +275,6 @@ func (v *SimpleNamedFragmentResponse) UnmarshalJSON(b []byte) error {
"Unable to unmarshal SimpleNamedFragmentResponse.RandomLeaf: %w", err)
}
}
return nil
}
@@ -19,7 +19,6 @@ type UnionNoFragmentsQueryRandomLeafArticle struct {
// UnionNoFragmentsQueryRandomLeafLeafContent is implemented by the following types:
// UnionNoFragmentsQueryRandomLeafArticle
// UnionNoFragmentsQueryRandomLeafVideo
//
// The GraphQL type's documentation follows.
//
// LeafContent represents content items that can't have child-nodes.
@@ -104,7 +103,6 @@ func (v *UnionNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error {
"Unable to unmarshal UnionNoFragmentsQueryResponse.RandomLeaf: %w", err)
}
}
return nil
}