include alias even if we don't need it

This commit is contained in:
Ben Kraft
2021-04-15 11:36:46 -07:00
parent e597cac74c
commit 136ac7729f
5 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ type getViewerResponse struct {
} }
type getViewerViewerUser struct { type getViewerViewerUser struct {
MyName string MyName string `json:"MyName"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
} }
+2 -2
View File
@@ -8,11 +8,11 @@ import (
) )
type QueryWithAliasResponse struct { type QueryWithAliasResponse struct {
User QueryWithAliasUser User QueryWithAliasUser `json:"User"`
} }
type QueryWithAliasUser struct { type QueryWithAliasUser struct {
ID mypkg.ID ID mypkg.ID `json:"ID"`
} }
func QueryWithAlias( func QueryWithAlias(
+2 -2
View File
@@ -12,8 +12,8 @@ type QueryWithDoubleAliasResponse struct {
} }
type QueryWithDoubleAliasUser struct { type QueryWithDoubleAliasUser struct {
ID mypkg.ID ID mypkg.ID `json:"ID"`
AlsoID mypkg.ID AlsoID mypkg.ID `json:"AlsoID"`
} }
func QueryWithDoubleAlias( func QueryWithDoubleAlias(
+2 -2
View File
@@ -22,8 +22,8 @@ type UsesEnumTwiceQueryOtherUser struct {
} }
type UsesEnumTwiceQueryResponse struct { type UsesEnumTwiceQueryResponse struct {
Me UsesEnumTwiceQueryMeUser Me UsesEnumTwiceQueryMeUser `json:"Me"`
OtherUser UsesEnumTwiceQueryOtherUser OtherUser UsesEnumTwiceQueryOtherUser `json:"OtherUser"`
} }
func UsesEnumTwiceQuery( func UsesEnumTwiceQuery(
+1 -1
View File
@@ -267,7 +267,7 @@ func (builder *typeBuilder) writeField(field field) error {
if builder.schema.Types[typ.Name()].IsAbstractType() { if builder.schema.Types[typ.Name()].IsAbstractType() {
// abstract types are handled in our UnmarshalJSON // abstract types are handled in our UnmarshalJSON
builder.WriteString(" `json:\"-\"`") builder.WriteString(" `json:\"-\"`")
} else if jsonName != goName { } else {
fmt.Fprintf(builder, " `json:\"%s\"`", jsonName) fmt.Fprintf(builder, " `json:\"%s\"`", jsonName)
} }
builder.WriteRune('\n') builder.WriteRune('\n')