zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

5.1.0 missing server not receiving operationName #1121

Closed Davete0302 closed 2 years ago

Davete0302 commented 2 years ago

When sending a request to the server operationName is missing from request, even after adding operationName in query constructor, is this expected? Also an additional question. is there a way to show in the actual query/request sent?

vincenzopalazzo commented 2 years ago

this looks like a malformed query for your server, we don't attach any operation name. However, without an example of stacktrace and query, it is not possible to help.

Davete0302 commented 2 years ago

I can't see the logs/stacktrace from backend. Is there a way to see the actual request sent? Would be really helpful.

Request

Query(
  options: QueryOptions(
    document: gql(DashboardGraphQL.accountDetailsQuery),
    operationName: 'accountDetails'
  ),
  builder: (QueryResult result,
      {VoidCallback refetch, FetchMore fetchMore}) {

Query

query AccountDetails {
    accountDetails {
      ... on AccountDetails {
        ibanList {
          accountId
          bicCode
          iban
        }
        accountType
        accountNumber
        accountNumberShort
        accountId
        ruid
        companyId
        accountDataOpened
        email
        mobile
        baseCurrency
        balanceInBaseCurrency
        lastTransactionDate
      }

      ... on ResponseErrors {
        errors {
          message
          code
          displayMessage

          ... on InternalError {
            message
            code
            displayMessage
            context
          }
        }
      }
    }
  }

Response

OperationException(linkException: ResponseFormatException(originalException: FormatException: Unexpected end of input (at character 1)

^
), graphqlErrors: [])
vincenzopalazzo commented 2 years ago

Maybe, you type from the operation name? https://graphql.org/learn/queries/#operation-name

and you have space also inside the operationName string

This is not a client problem, but just a typo

Davete0302 commented 2 years ago

Edited operationName, it was a typo it originally does not have space. Still the same issue though. Also Is there a way to see the actual request sent? Would be really helpful.

vincenzopalazzo commented 2 years ago

The operationName it is the "query name" right? so in your case it is AccountDetails right?

vincenzopalazzo commented 2 years ago

actual request sent

You should implement a custom link

Davete0302 commented 2 years ago

Yes, actually tried both 'AccountDetails' and 'accountDetails'. Also please answer this. 'Is there a way to see the actual request sent?' It's ok if there's none. Tested with 3 different request both with correct operationName, one worked and 2 did not. So I'm wondering what request was sent. Alright will try to implement custom link.

vincenzopalazzo commented 2 years ago

Also please answer this. 'Is there a way to see the actual request sent?' It's ok if there's none.

You should implement a custom link (here)

vincenzopalazzo commented 2 years ago

Closing for inactivity! please feel free to reopen this