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

options.variables final #1141

Closed ITASerus closed 2 years ago

ITASerus commented 2 years ago

Hi guys, this morning I was updating to Flutter 3 but then I rolled back to Flutter 2.10 sue to some incompatibilities. The problem is that now, even if I removed all the changes, the variables parameter of QueryOptions is marked as final even if in the QueryOption class it's not

Anyone with a similar problem?

Prior this problem, I was capable to do something like this:

final QueryOptions options = QueryOptions(
        document: ...,
        fetchPolicy: FetchPolicy.cacheAndNetwork,
    );

   ...
   ...
   options.variables = {....};
vincenzopalazzo commented 2 years ago

Mh! we have a problem right now that we point to solve before the next week with flutter #1134 However, nothing with final stuff, can you post the error that you receive?

Thanks!

ITASerus commented 2 years ago

Hi! thanks for the fast reply

The error is simply

'variables' can't be used as a setter because it's final.
Try finding a different setter, or making 'variables' non-final.

and is triggered when I try to assign some value to the variables field of a QueryOptions instance after the initialization.

I always used the graphql package version ^5.0.0. Nothing is changed but now I cannot assing a value to that field of QueryOptions

budde377 commented 2 years ago

@ITASerus we've recently made the query options immutable, instead of updating the variables on the options you should create a new options instance. Sorry for the problem this is causing.

ITASerus commented 2 years ago

@budde377

oh ok, no problem! Good to know then! I wasn't sure if it was a problem of the library or an error caused by the rollback to flutter 2.10

In any case, thanks for all the effort you all are putting in this library <3