Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphql/e2e/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ func RunAll(t *testing.T) {
t.Run("numUids test", testNumUids)
t.Run("empty delete", mutationEmptyDelete)
t.Run("duplicate xid in single mutation", deepMutationDuplicateXIDsSameObjectTest)
t.Run("query typename in mutation payload", queryTypenameInMutationPayload)
t.Run("query typename in mutation", queryTypenameInMutation)
t.Run("ensure alias in mutation payload", ensureAliasInMutationPayload)
t.Run("mutations have extensions", mutationsHaveExtensions)
t.Run("alias works for mutations", mutationsWithAlias)
Expand Down
6 changes: 5 additions & 1 deletion graphql/e2e/common/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3483,9 +3483,11 @@ func getXidFilter(xidKey string, xidVals []string) map[string]interface{} {
return filter
}

func queryTypenameInMutationPayload(t *testing.T) {
func queryTypenameInMutation(t *testing.T) {
addStateParams := &GraphQLParams{
Query: `mutation {
__typename
a:__typename
addState(input: [{xcode: "S1", name: "State1"}]) {
state {
__typename
Expand All @@ -3501,6 +3503,8 @@ func queryTypenameInMutationPayload(t *testing.T) {
RequireNoGQLErrors(t, gqlResponse)

addStateExpected := `{
"__typename":"Mutation",
"a":"Mutation",
"addState": {
"state": [{
"__typename": "State",
Expand Down
13 changes: 11 additions & 2 deletions graphql/resolve/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ func (rf *resolverFactory) WithSchemaIntrospection() ResolverFactory {
WithQueryResolver("__typename",
func(q schema.Query) QueryResolver {
return QueryResolverFunc(resolveIntrospection)
}).
WithMutationResolver("__typename",
func(m schema.Mutation) MutationResolver {
return MutationResolverFunc(func(ctx context.Context, m schema.Mutation) (*Resolved, bool) {
return &Resolved{
Data: map[string]interface{}{"__typename": "Mutation"},
Field: m,
Err: nil,
Extensions: nil,
}, resolverSucceeded
})
})
}

Expand Down Expand Up @@ -375,7 +386,6 @@ func (rf *resolverFactory) queryResolverFor(query schema.Query) QueryResolver {
if resolver, ok := rf.queryResolvers[query.Name()]; ok {
return mws.Then(resolver(query))
}

return rf.queryError
}

Expand All @@ -386,7 +396,6 @@ func (rf *resolverFactory) mutationResolverFor(mutation schema.Mutation) Mutatio
if resolver, ok := rf.mutationResolvers[mutation.Name()]; ok {
return mws.Then(resolver(mutation))
}

return rf.mutationError
}

Expand Down