[Bug] upmost __typename in mutation finds no resolver

Report a Dgraph Bug

Error Message: “__typename was not executed because no suitable resolver could be found - this indicates a resolver or validation bug. Please let us know by filing an issue.”

this error message occurs if one tries to include __typename under mutation.

What version of Dgraph are you using?

v20.11.0

Have you tried reproducing the issue with the latest release?

I think this is the latest release

What is the hardware spec (RAM, OS)?

RAM: 15GB
OS: Ubuntu 20.04.1 LTS

Steps to reproduce the issue (command/config used to run Dgraph).

mutation:

mutation addTest($input: [AddTestInput!]!) {
  __typename   <- this one
  addTest(input: $input) {
    __typename
    test {
      __typename
      name
    }
  }
}

query variables:

{
	"input": [
		{
			"name": "john"
		}
	]
}

schema type:

type Test {
    name: String!
}

result:

{
  "errors": [
    {
      "message": "__typename was not executed because no suitable resolver could be found - this indicates a resolver or validation bug. Please let us know by filing an issue."
    },
    {
      "message": "Mutation addTest was not executed because of a previous error.",
      "locations": [
        {
          "line": 3,
          "column": 3
        }
      ]
    }
  ],
.
.
.

Expected behaviour and actual result.

result:

{
  "data": {
    "__typename": "Mutation",
    "addTest": {
      "__typename": "AddTestPayload",
      "test": [
        {
          "__typename": "Test",
          "name": "john"
        }
      ]
    }
  },
.
.
.

Hi @noobloser, this behavior is not allowed. You can’t query __typename or anything on type mutation.

Hello @JatinDevDG,
thank your for your response.
If you know I’d like to know if that is a deliberate design decision or just so happens to be,
as I can get the __typename of a query just fine.

1 Like

The reason this is such a huge problem at the moment, is the
main flutter library for graphql by default puts the __typename also under mutations.
This seems to be an issue purely with dgraph, as other have not mentioned such an issue.

Because I quite like working with the library and dgraph as both are awesome implementations imo, I’d like to resolve this issue to limit the entry barrier for new users that do not want to deviate from the default path of the library.

Github issue I refer to: GraphQL-Flutter #784

Yeah, i guess it’s better to change that in library. We will also see if it’s required behaviour and then discuss internally.

Hi @noobloser, we discussed it and found that it’s a bug. We will create a ticket for this and fix it soon. Thanks.

1 Like

This is awesome news. Thanks to you and the team.
I’d apprechiate it if you post here, when the solution is implemented, so I can close the librarys github issue accordingly.
Till then, thanks again.

1 Like

@JatinDevDG @noobloser I faced the same issue as well. Had filed an issue in GraphQL Mesh here: Mesh SDK execution fails · Issue #1339 · ardatan/graphql-mesh · GitHub where we narrowed it all down to this issue.

My mutation from Mesh looked like this:

mutation ($graphqlTools0_updatedAuthMethod: UpdateAuthMethodInput!) {
  graphqlTools0___typename: __typename
  graphqlTools0___typename: __typename
  graphqlTools0___typename: __typename
  graphqlTools0___gqtld0__: __typename
  graphqlTools0___typename: __typename
  graphqlTools0___gqtld1__: updateAuthMethod(
    input: $graphqlTools0_updatedAuthMethod
  ) {
    __typename
    __typename
    __typename
    authMethod {
      __typename
      __typename
      __typename
      id
      __typename
      __typename
      __typename
      authKey
      __typename
      __typename
      __typename
      verificationStatus
      __typename
      __typename
      __typename
      authProviderMethod {
        __typename
        __typename
        __typename
        id
      }
      __typename
      __typename
      __typename
      metadata
      __typename
      __typename
      __typename
      account {
        __typename
        __typename
        __typename
        id
      }
      __typename
      __typename
      __typename
      creationTime
    }
  }
}

and returned the same error:

Hi @noobloser @tvvignesh, fix for this issue is merged in the master branch.
PR: fix(GraphQL): This PR allow to use __typename in mutation. by JatinDevDG · Pull Request #7285 · dgraph-io/dgraph · GitHub

3 Likes

I have the same issue but with query now.
OperationException(linkException: null, graphqlErrors: [GraphQLError(message: Operations not allowed – [__typename], locations: null, path: null, extensions: null)])

I use graphql 5.1.1 library for flutter.

Corresponding issue is described here.

https://github.com/zino-hofmann/graphql-flutter/issues/784#issuecomment-749005581

and I recreated it in the explorer:


query getUserProfile($username: String!) {
  __typename  
  getUser(username: $username) {
        __typename
        username
    }
}

returns

{
  "data": null,
  "errors": [
    {
      "message": "Operations not allowed -- [__typename]"
    }
  ]
}

Mutation does not work either so maybe it was not merged into the cloud.

mutation MyMutation2($name: String = "", $country: String = "") {
  __typename
  addCity(input: {name: $name, country: {name: $country}}) {
    __typename
    city {
      id
      name
    }
  }
}


{
  "data": null,
  "errors": [
    {
      "message": "Operations not allowed -- [__typename]"
    }
  ]
}
type Country{
  id: ID!
  name: String
  region: [Region!] @hasInverse(field: country)
  cities: [City!] @hasInverse(field: country)
  
} 
    
type Region{
  id: ID!
  name: String
  country: Country @hasInverse(field: region)
  guide: [Guide]
  
}

type City{
  id: ID!
  name:String
  country: Country! @hasInverse(field:cities)
  location: Point
  
}