Make test ID type actually exist

This way I can start to test that the code compiles.
This commit is contained in:
Ben Kraft
2021-06-03 11:31:23 -07:00
parent c2e7dc4e5b
commit 3c11f07e62
17 changed files with 84 additions and 81 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ func TestGenerate(t *testing.T) {
Generated: goFilename,
ExportOperations: queriesFilename,
Scalars: map[string]string{
"ID": "github.com/me/mypkg.ID",
"ID": "github.com/Khan/genqlient/internal/testutil.ID",
"DateTime": "time.Time",
"Junk": "interface{}",
"ComplexJunk": "[]map[string]*[]*map[string]interface{}",
+2 -2
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// InputEnumQueryResponse is returned by InputEnumQuery on success.
@@ -21,7 +21,7 @@ type InputEnumQueryUsersWithRoleUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
// Role is a type a user may have.
+5 -5
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// InputObjectQueryResponse is returned by InputObjectQuery on success.
@@ -24,7 +24,7 @@ type InputObjectQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
// Role is a type a user may have.
@@ -50,9 +50,9 @@ type UserQueryInput struct {
Email string `json:"email"`
Name string `json:"name"`
// id looks the user up by ID. It's a great way to look up users.
Id mypkg.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
Id testutil.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
}
func InputObjectQuery(
+17 -17
View File
@@ -6,7 +6,7 @@ import (
"encoding/json"
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// InterfaceNestingResponse is returned by InterfaceNesting on success.
@@ -17,7 +17,7 @@ type InterfaceNestingResponse struct {
// 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"`
Id testutil.ID `json:"id"`
Children []InterfaceNestingRootTopicChildrenContent `json:"-"`
}
@@ -71,7 +71,7 @@ func (v *InterfaceNestingRootTopic) UnmarshalJSON(b []byte) error {
// 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"`
Id testutil.ID `json:"id"`
Parent InterfaceNestingRootTopicChildrenArticleParentTopic `json:"parent"`
}
@@ -81,7 +81,7 @@ func (v InterfaceNestingRootTopicChildrenArticle) implementsGraphQLInterfaceInte
// 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"`
Id testutil.ID `json:"id"`
Children []InterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent `json:"-"`
}
@@ -135,7 +135,7 @@ func (v *InterfaceNestingRootTopicChildrenArticleParentTopic) UnmarshalJSON(b []
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() {
@@ -152,7 +152,7 @@ type InterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent interfac
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() {
@@ -161,7 +161,7 @@ func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenTopic) implem
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenArticleParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenArticleParentTopicChildrenContent() {
@@ -178,7 +178,7 @@ type InterfaceNestingRootTopicChildrenContent interface {
// 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"`
Id testutil.ID `json:"id"`
Parent InterfaceNestingRootTopicChildrenTopicParentTopic `json:"parent"`
}
@@ -188,7 +188,7 @@ func (v InterfaceNestingRootTopicChildrenTopic) implementsGraphQLInterfaceInterf
// 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"`
Id testutil.ID `json:"id"`
Children []InterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent `json:"-"`
}
@@ -242,7 +242,7 @@ func (v *InterfaceNestingRootTopicChildrenTopicParentTopic) UnmarshalJSON(b []by
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() {
@@ -259,7 +259,7 @@ type InterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent interface
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() {
@@ -268,7 +268,7 @@ func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenTopic) implemen
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenTopicParentTopicChildrenContent() {
@@ -277,7 +277,7 @@ func (v InterfaceNestingRootTopicChildrenTopicParentTopicChildrenVideo) implemen
// 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"`
Id testutil.ID `json:"id"`
Parent InterfaceNestingRootTopicChildrenVideoParentTopic `json:"parent"`
}
@@ -287,7 +287,7 @@ func (v InterfaceNestingRootTopicChildrenVideo) implementsGraphQLInterfaceInterf
// 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"`
Id testutil.ID `json:"id"`
Children []InterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent `json:"-"`
}
@@ -341,7 +341,7 @@ func (v *InterfaceNestingRootTopicChildrenVideoParentTopic) UnmarshalJSON(b []by
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenVideoParentTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent() {
@@ -358,7 +358,7 @@ type InterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent interface
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenVideoParentTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent() {
@@ -367,7 +367,7 @@ func (v InterfaceNestingRootTopicChildrenVideoParentTopicChildrenTopic) implemen
// 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"`
Id testutil.ID `json:"id"`
}
func (v InterfaceNestingRootTopicChildrenVideoParentTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNestingRootTopicChildrenVideoParentTopicChildrenContent() {
+8 -8
View File
@@ -6,7 +6,7 @@ import (
"encoding/json"
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// InterfaceNoFragmentsQueryResponse is returned by InterfaceNoFragmentsQuery on success.
@@ -17,7 +17,7 @@ type InterfaceNoFragmentsQueryResponse struct {
// 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"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
Children []InterfaceNoFragmentsQueryRootTopicChildrenContent `json:"-"`
}
@@ -72,8 +72,8 @@ func (v *InterfaceNoFragmentsQueryRootTopic) UnmarshalJSON(b []byte) error {
// 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"`
Name string `json:"name"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
}
func (v InterfaceNoFragmentsQueryRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
@@ -90,8 +90,8 @@ type InterfaceNoFragmentsQueryRootTopicChildrenContent interface {
// 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"`
Name string `json:"name"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
}
func (v InterfaceNoFragmentsQueryRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
@@ -100,8 +100,8 @@ func (v InterfaceNoFragmentsQueryRootTopicChildrenTopic) implementsGraphQLInterf
// 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"`
Name string `json:"name"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
}
func (v InterfaceNoFragmentsQueryRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
+2 -2
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// ListInputQueryResponse is returned by ListInputQuery on success.
@@ -24,7 +24,7 @@ type ListInputQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
func ListInputQuery(
+6 -6
View File
@@ -6,7 +6,7 @@ import (
"time"
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// OmitEmptyQueryResponse is returned by OmitEmptyQuery on success.
@@ -29,7 +29,7 @@ type OmitEmptyQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
// OmitEmptyQueryUsersUser includes the requested fields of the GraphQL type User.
@@ -40,7 +40,7 @@ type OmitEmptyQueryUsersUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
// Role is a type a user may have.
@@ -66,9 +66,9 @@ type UserQueryInput struct {
Email string `json:"email"`
Name string `json:"name"`
// id looks the user up by ID. It's a great way to look up users.
Id mypkg.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
Id testutil.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
}
func OmitEmptyQuery(
+10 -10
View File
@@ -6,7 +6,7 @@ import (
"time"
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// PointersQueryOtherUser includes the requested fields of the GraphQL type User.
@@ -17,7 +17,7 @@ type PointersQueryOtherUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id *mypkg.ID `json:"id"`
Id *testutil.ID `json:"id"`
}
// PointersQueryResponse is returned by PointersQuery on success.
@@ -43,11 +43,11 @@ type PointersQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id *mypkg.ID `json:"id"`
Roles []*Role `json:"roles"`
Name *string `json:"name"`
Emails []*string `json:"emails"`
EmailsNoPtr []string `json:"emailsNoPtr"`
Id *testutil.ID `json:"id"`
Roles []*Role `json:"roles"`
Name *string `json:"name"`
Emails []*string `json:"emails"`
EmailsNoPtr []string `json:"emailsNoPtr"`
}
// Role is a type a user may have.
@@ -73,9 +73,9 @@ type UserQueryInput struct {
Email *string `json:"email"`
Name *string `json:"name"`
// id looks the user up by ID. It's a great way to look up users.
Id *mypkg.ID `json:"id"`
Role *Role `json:"role"`
Names []*string `json:"names"`
Id *testutil.ID `json:"id"`
Role *Role `json:"role"`
Names []*string `json:"names"`
}
func PointersQuery(
+10 -10
View File
@@ -6,7 +6,7 @@ import (
"time"
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// PointersQueryOtherUser includes the requested fields of the GraphQL type User.
@@ -17,7 +17,7 @@ type PointersQueryOtherUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
// PointersQueryResponse is returned by PointersQuery on success.
@@ -43,11 +43,11 @@ type PointersQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Roles []Role `json:"roles"`
Name *string `json:"name"`
Emails []*string `json:"emails"`
EmailsNoPtr []*string `json:"emailsNoPtr"`
Id testutil.ID `json:"id"`
Roles []Role `json:"roles"`
Name *string `json:"name"`
Emails []*string `json:"emails"`
EmailsNoPtr []*string `json:"emailsNoPtr"`
}
// Role is a type a user may have.
@@ -73,9 +73,9 @@ type UserQueryInput struct {
Email string `json:"email"`
Name string `json:"name"`
// id looks the user up by ID. It's a great way to look up users.
Id mypkg.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
Id testutil.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
}
func PointersQuery(
+3 -3
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// QueryWithAliasResponse is returned by QueryWithAlias on success.
@@ -24,11 +24,11 @@ type QueryWithAliasUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
ID mypkg.ID `json:"ID"`
ID testutil.ID `json:"ID"`
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
OtherID mypkg.ID `json:"otherID"`
OtherID testutil.ID `json:"otherID"`
}
func QueryWithAlias(
+3 -3
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// QueryWithDoubleAliasResponse is returned by QueryWithDoubleAlias on success.
@@ -24,11 +24,11 @@ type QueryWithDoubleAliasUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
ID mypkg.ID `json:"ID"`
ID testutil.ID `json:"ID"`
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
AlsoID mypkg.ID `json:"AlsoID"`
AlsoID testutil.ID `json:"AlsoID"`
}
func QueryWithDoubleAlias(
+2 -2
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// SimpleInputQueryResponse is returned by SimpleInputQuery on success.
@@ -24,7 +24,7 @@ type SimpleInputQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
func SimpleInputQuery(
+3 -3
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// SimpleMutationCreateUser includes the requested fields of the GraphQL type User.
@@ -15,8 +15,8 @@ type SimpleMutationCreateUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Name string `json:"name"`
Id testutil.ID `json:"id"`
Name string `json:"name"`
}
// SimpleMutationResponse is returned by SimpleMutation on success.
+2 -2
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// SimpleQueryResponse is returned by SimpleQuery on success.
@@ -24,7 +24,7 @@ type SimpleQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
func SimpleQuery(
+2 -2
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// TypeNameQueryResponse is returned by TypeNameQuery on success.
@@ -25,7 +25,7 @@ type TypeNameQueryUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
func TypeNameQuery(
+5 -5
View File
@@ -4,7 +4,7 @@ package test
import (
"github.com/Khan/genqlient/graphql"
"github.com/me/mypkg"
"github.com/Khan/genqlient/internal/testutil"
)
// Role is a type a user may have.
@@ -38,7 +38,7 @@ type unexportedUser struct {
// id is the user's ID.
//
// It is stable, unique, and opaque, like all good IDs.
Id mypkg.ID `json:"id"`
Id testutil.ID `json:"id"`
}
// UserQueryInput is the argument to Query.users.
@@ -50,9 +50,9 @@ type userQueryInput struct {
Email string `json:"email"`
Name string `json:"name"`
// id looks the user up by ID. It's a great way to look up users.
Id mypkg.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
Id testutil.ID `json:"id"`
Role Role `json:"role"`
Names []string `json:"names"`
}
func unexported(
+3
View File
@@ -0,0 +1,3 @@
package testutil
type ID string