add support for custom scalars -- mainly adding proper import machinery
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
query convertTimezone($dt: DateTime!, $tz: String) {
|
||||
convert(dt: $dt, tz: $tz)
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package test
|
||||
|
||||
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
)
|
||||
|
||||
type convertTimezoneResponse struct {
|
||||
Convert time.Time `json:"convert"`
|
||||
}
|
||||
|
||||
func convertTimezone(
|
||||
client graphql.Client,
|
||||
dt time.Time,
|
||||
tz string,
|
||||
) (*convertTimezoneResponse, error) {
|
||||
variables := map[string]interface{}{
|
||||
"dt": dt,
|
||||
"tz": tz,
|
||||
}
|
||||
|
||||
var retval convertTimezoneResponse
|
||||
err := client.MakeRequest(
|
||||
nil,
|
||||
"convertTimezone",
|
||||
`
|
||||
query convertTimezone ($dt: DateTime!, $tz: String) {
|
||||
convert(dt: $dt, tz: $tz)
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
variables,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"operations": [
|
||||
{
|
||||
"operationName": "convertTimezone",
|
||||
"query": "\nquery convertTimezone ($dt: DateTime!, $tz: String) {\n\tconvert(dt: $dt, tz: $tz)\n}\n",
|
||||
"sourceLocation": "testdata/queries/DateTime.graphql"
|
||||
}
|
||||
]
|
||||
}
|
||||
+3
-2
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type InputObjectQueryResponse struct {
|
||||
@@ -11,7 +12,7 @@ type InputObjectQueryResponse struct {
|
||||
}
|
||||
|
||||
type InputObjectQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
}
|
||||
|
||||
type Role string
|
||||
@@ -24,7 +25,7 @@ const (
|
||||
type UserQueryInput struct {
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Role Role `json:"role"`
|
||||
Names []string `json:"names"`
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type InterfaceNoFragmentsQueryResponse struct {
|
||||
@@ -13,7 +14,7 @@ type InterfaceNoFragmentsQueryResponse struct {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopic struct {
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []InterfaceNoFragmentsQueryRootTopicChildrenContent `json:"-"`
|
||||
}
|
||||
@@ -66,8 +67,8 @@ func (v *InterfaceNoFragmentsQueryRootTopic) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenArticle struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
@@ -78,16 +79,16 @@ type InterfaceNoFragmentsQueryRootTopicChildrenContent interface {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenTopic struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenVideo struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type ListInputQueryResponse struct {
|
||||
@@ -11,7 +12,7 @@ type ListInputQueryResponse struct {
|
||||
}
|
||||
|
||||
type ListInputQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
}
|
||||
|
||||
func ListInputQuery(
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type QueryWithAliasResponse struct {
|
||||
@@ -11,7 +12,7 @@ type QueryWithAliasResponse struct {
|
||||
}
|
||||
|
||||
type QueryWithAliasUser struct {
|
||||
ID string
|
||||
ID mypkg.ID
|
||||
}
|
||||
|
||||
func QueryWithAlias(
|
||||
|
||||
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type QueryWithDoubleAliasResponse struct {
|
||||
@@ -11,8 +12,8 @@ type QueryWithDoubleAliasResponse struct {
|
||||
}
|
||||
|
||||
type QueryWithDoubleAliasUser struct {
|
||||
ID string
|
||||
AlsoID string
|
||||
ID mypkg.ID
|
||||
AlsoID mypkg.ID
|
||||
}
|
||||
|
||||
func QueryWithDoubleAlias(
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type SimpleInputQueryResponse struct {
|
||||
@@ -11,7 +12,7 @@ type SimpleInputQueryResponse struct {
|
||||
}
|
||||
|
||||
type SimpleInputQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
}
|
||||
|
||||
func SimpleInputQuery(
|
||||
|
||||
+3
-2
@@ -4,11 +4,12 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type SimpleMutationCreateUser struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SimpleMutationResponse struct {
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type SimpleQueryResponse struct {
|
||||
@@ -11,7 +12,7 @@ type SimpleQueryResponse struct {
|
||||
}
|
||||
|
||||
type SimpleQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
}
|
||||
|
||||
func SimpleQuery(
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type TypeNameQueryResponse struct {
|
||||
@@ -11,8 +12,8 @@ type TypeNameQueryResponse struct {
|
||||
}
|
||||
|
||||
type TypeNameQueryUser struct {
|
||||
Typename string `json:"__typename"`
|
||||
Id string `json:"id"`
|
||||
Typename string `json:"__typename"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
}
|
||||
|
||||
func TypeNameQuery(
|
||||
|
||||
+3
@@ -1,3 +1,5 @@
|
||||
scalar DateTime
|
||||
|
||||
enum Role {
|
||||
STUDENT
|
||||
TEACHER
|
||||
@@ -60,6 +62,7 @@ type Query {
|
||||
user(query: UserQueryInput): User
|
||||
root: Topic!
|
||||
randomLeaf: LeafContent!
|
||||
convert(dt: DateTime!, tz: String): DateTime!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ package test
|
||||
|
||||
import (
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
"github.com/me/mypkg"
|
||||
)
|
||||
|
||||
type Role string
|
||||
@@ -18,13 +19,13 @@ type unexportedResponse struct {
|
||||
}
|
||||
|
||||
type unexportedUser struct {
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
}
|
||||
|
||||
type userQueryInput struct {
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
Id mypkg.ID `json:"id"`
|
||||
Role Role `json:"role"`
|
||||
Names []string `json:"names"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user