Graphql-flutter: [Beta 2] query keyword is required in all queries

Created on 23 Apr 2019  路  11Comments  路  Source: zino-app/graphql-flutter

Describe the bug
Previously, you could make a query like so:

const String getUsers = """
  {
    users {
      id
      name
    }
  }
"""

however, now the query keyword is required, even if no variables are being passed.

const String getUsers = """
  query getUsers {
    users {
      id
      name
    }
  }
"""

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to make the first query (any query without query
  2. Failure

Expected behavior
query should not be required.

bug released released on @beta

Most helpful comment

+1. Query builder should support default behavior of no query keyword.

Moreover, request would fail by unknown operation if the query keyword is now followed by a name.

For example this query should work but not:

query {
    items {
        id
        name
    }
}

It has to be:

query GetItemsByOrder {
    items {
        id
        name
    }
}

All 11 comments

+1. Query builder should support default behavior of no query keyword.

Moreover, request would fail by unknown operation if the query keyword is now followed by a name.

For example this query should work but not:

query {
    items {
        id
        name
    }
}

It has to be:

query GetItemsByOrder {
    items {
        id
        name
    }
}

When we use query or mutation without Operation name it will add operation name like
_operationName ??= 'UNNAMED/' + document.hashCode.toString();

And my backend hasura graphql server gives error invalid operation

It's not in just query when I run mutation from bloc (not using mutation widget) throws this error.

@Kyle-Mendes How is this a valid query?

const String getUsers = """
  users {
    id
    name
  }
"""

Even if the query keyword is omitted shouldn't there always be wrapping brackets like so:

const String getUsers = """
  {
    users {
      id
      name
    }
  }
"""

@HofmannZ Oops! I accidentally typed it out wrong :) Good catch!

(fixed in the issue body)

yeah this looks like a regression - probably need to decouple operationName from the operation identification functionality I added the default for.

I've been a bit busy, but I should be able to get to this later this week

@micimize any progress?

@endigo I haven't had time to work on it - I would update here proactively if I had

closed by #276

:tada: This issue has been resolved in version 1.0.1-beta.8 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vanelizarov picture vanelizarov  路  3Comments

micimize picture micimize  路  4Comments

milind-solutelabs picture milind-solutelabs  路  3Comments

rullyalves picture rullyalves  路  4Comments

micimize picture micimize  路  4Comments