Make output deterministic for graphql interfaces (#209)
We noticed that the output from genqlient can be non-deterministic when a graphql query queries a field that's an interface. This PR fixes that by sorting the types as soon as we extract them from the schema.
This commit is contained in:
Vendored
+28
-28
@@ -134,8 +134,8 @@ func (v *InterfaceNestingRootTopicChildrenArticle) GetParent() InterfaceNestingR
|
||||
//
|
||||
// InterfaceNestingRootTopicChildrenContent is implemented by the following types:
|
||||
// InterfaceNestingRootTopicChildrenArticle
|
||||
// InterfaceNestingRootTopicChildrenVideo
|
||||
// InterfaceNestingRootTopicChildrenTopic
|
||||
// InterfaceNestingRootTopicChildrenVideo
|
||||
// The GraphQL type's documentation follows.
|
||||
//
|
||||
// Content is implemented by various types like Article, Video, and Topic.
|
||||
@@ -154,10 +154,10 @@ type InterfaceNestingRootTopicChildrenContent interface {
|
||||
|
||||
func (v *InterfaceNestingRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() {
|
||||
}
|
||||
func (v *InterfaceNestingRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() {
|
||||
}
|
||||
func (v *InterfaceNestingRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() {
|
||||
}
|
||||
func (v *InterfaceNestingRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
func __unmarshalInterfaceNestingRootTopicChildrenContent(b []byte, v *InterfaceNestingRootTopicChildrenContent) error {
|
||||
if string(b) == "null" {
|
||||
@@ -176,12 +176,12 @@ func __unmarshalInterfaceNestingRootTopicChildrenContent(b []byte, v *InterfaceN
|
||||
case "Article":
|
||||
*v = new(InterfaceNestingRootTopicChildrenArticle)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "Video":
|
||||
*v = new(InterfaceNestingRootTopicChildrenVideo)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "Topic":
|
||||
*v = new(InterfaceNestingRootTopicChildrenTopic)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "Video":
|
||||
*v = new(InterfaceNestingRootTopicChildrenVideo)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "":
|
||||
return fmt.Errorf(
|
||||
"response was missing Content.__typename")
|
||||
@@ -203,14 +203,6 @@ func __marshalInterfaceNestingRootTopicChildrenContent(v *InterfaceNestingRootTo
|
||||
*InterfaceNestingRootTopicChildrenArticle
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case *InterfaceNestingRootTopicChildrenVideo:
|
||||
typename = "Video"
|
||||
|
||||
result := struct {
|
||||
TypeName string `json:"__typename"`
|
||||
*InterfaceNestingRootTopicChildrenVideo
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case *InterfaceNestingRootTopicChildrenTopic:
|
||||
typename = "Topic"
|
||||
|
||||
@@ -219,6 +211,14 @@ func __marshalInterfaceNestingRootTopicChildrenContent(v *InterfaceNestingRootTo
|
||||
*InterfaceNestingRootTopicChildrenTopic
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case *InterfaceNestingRootTopicChildrenVideo:
|
||||
typename = "Video"
|
||||
|
||||
result := struct {
|
||||
TypeName string `json:"__typename"`
|
||||
*InterfaceNestingRootTopicChildrenVideo
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case nil:
|
||||
return []byte("null"), nil
|
||||
default:
|
||||
@@ -341,8 +341,8 @@ func (v *InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle) Get
|
||||
//
|
||||
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenContent is implemented by the following types:
|
||||
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle
|
||||
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo
|
||||
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenTopic
|
||||
// InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo
|
||||
// The GraphQL type's documentation follows.
|
||||
//
|
||||
// Content is implemented by various types like Article, Video, and Topic.
|
||||
@@ -359,10 +359,10 @@ type InterfaceNestingRootTopicChildrenContentParentTopicChildrenContent interfac
|
||||
|
||||
func (v *InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent() {
|
||||
}
|
||||
func (v *InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent() {
|
||||
}
|
||||
func (v *InterfaceNestingRootTopicChildrenContentParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent() {
|
||||
}
|
||||
func (v *InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent() {
|
||||
}
|
||||
|
||||
func __unmarshalInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent(b []byte, v *InterfaceNestingRootTopicChildrenContentParentTopicChildrenContent) error {
|
||||
if string(b) == "null" {
|
||||
@@ -381,12 +381,12 @@ func __unmarshalInterfaceNestingRootTopicChildrenContentParentTopicChildrenConte
|
||||
case "Article":
|
||||
*v = new(InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "Video":
|
||||
*v = new(InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "Topic":
|
||||
*v = new(InterfaceNestingRootTopicChildrenContentParentTopicChildrenTopic)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "Video":
|
||||
*v = new(InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo)
|
||||
return json.Unmarshal(b, *v)
|
||||
case "":
|
||||
return fmt.Errorf(
|
||||
"response was missing Content.__typename")
|
||||
@@ -408,14 +408,6 @@ func __marshalInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent
|
||||
*InterfaceNestingRootTopicChildrenContentParentTopicChildrenArticle
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case *InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo:
|
||||
typename = "Video"
|
||||
|
||||
result := struct {
|
||||
TypeName string `json:"__typename"`
|
||||
*InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case *InterfaceNestingRootTopicChildrenContentParentTopicChildrenTopic:
|
||||
typename = "Topic"
|
||||
|
||||
@@ -424,6 +416,14 @@ func __marshalInterfaceNestingRootTopicChildrenContentParentTopicChildrenContent
|
||||
*InterfaceNestingRootTopicChildrenContentParentTopicChildrenTopic
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case *InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo:
|
||||
typename = "Video"
|
||||
|
||||
result := struct {
|
||||
TypeName string `json:"__typename"`
|
||||
*InterfaceNestingRootTopicChildrenContentParentTopicChildrenVideo
|
||||
}{typename, v}
|
||||
return json.Marshal(result)
|
||||
case nil:
|
||||
return []byte("null"), nil
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user