Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter (graphql_flutter + gql): Found this candidate, but the arguments don't match

Tags:

flutter

dart

When trying to build app (iOS), getting the following output:

Removing references to graphql_flutter within the app gets rid of these errors.

I've tried every single channel for Flutter and issue persists across all.

../../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql-5.0.0/lib/src/core/query_manager.dart:427:23: Error: Required named parameter 'response' must be provided.
              Response(data: cachedData),
                      ^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dart:23:9: Context: Found this candidate, but the arguments don't match.
  const Response({
        ^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_link-0.4.0/lib/src/response_parser.dart:10:64: Error: Required named parameter 'response' must be provided.
  Response parseResponse(Map<String, dynamic> body) => Response(
                                                               ^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dart:23:9: Context: Found this candidate, but the arguments don't match.
  const Response({
        ^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_http_link-0.4.0/lib/src/link.dart:128:19: Error: Required named parameter 'response' must be provided.
    yield Response(
                  ^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dart:23:9: Context: Found this candidate, but the arguments don't match.
  const Response({

From pubspec.yaml:

graphql_flutter: ^5.0.0
gql: ^0.13.0

From flutter doctor (Have not set up Android yet)

[✓] Flutter (Channel stable, 2.5.3, on macOS 11.5.2 20G95 darwin-x64, locale en-US)
    • Flutter version 2.5.3 at /Users/justin/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/justin/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.61.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.27.0

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • BB5BF139-9146-4AC0-8316-7D044BD283B8 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 95.0.4638.69

! Doctor found issues in 1 category.
like image 390
Just a Flutter dev Avatar asked Nov 03 '21 22:11

Just a Flutter dev


People also ask

How to use GraphQL query in flutter?

In GraphQL, a query allows you to explicitly tell the API that you are only requesting data from the server. In a traditional RESTful API, this is equivalent to a GET method request. Your first goal is to retrieve the users from the server, and display it on a list. a. In the users.page.dart, import the graphql_flutter dependency b.

Is it possible to use flutter-GraphQL with Apollo?

You can setup authentication headers and other custom links just like you do with Apollo Graphql However note that flutter-graphql does not inject __typename into operations the way apollo does, so if you aren't careful to request them in your query, this normalization scheme is not possible. dataIdFromObject is required and has no defaults.

How to use runmutation in GraphQL?

With runMutation, you can tell the GraphQL client when exactly do you need to modify a data in the server. You can call this function within the scope of the Mutation builder. In addition, this is where you pass the data to the variables from the insertUser () mutation. e.

Why use GraphQL with Dart streams?

GraphQL brings many benefits, both to the client: devices will need less requests, and therefore reduce data useage. And to the programer: requests are arguable, they have the same structure as the request. This project combines the benefits of GraphQL with the benefits of Streams in Dart to deliver a high performace client.


1 Answers

TLDR; This issue is due to gql_exec containing a VERY RECENT breaking change in regards to the parameters which dependent libraries don't have implemented yet.

To fix to this use one of the following:

  • use code fragment below in your pubspec.lock file and don't run an upgrade until this breaking change is resolved between the libraries. (quickest solution)
  • to use fixed versions until the dependent libraries support this functionality. (better but slower solution)
  • gql_exec update their code to ensure this isn't a breaking change using a PATCH number (refer to: SEMVER). (best solution but could take a while)

For reference from our pubspec.lock file which we are using the following versions which build

gql:
    dependency: "direct main"
    description:
      name: gql
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.13.1-alpha+1633799193898"
  gql_build:
    dependency: "direct dev"
    description:
      name: gql_build
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.0-alpha+1633799193977"
  gql_code_builder:
    dependency: transitive
    description:
      name: gql_code_builder
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.0-alpha+1633799193964"
  gql_dedupe_link:
    dependency: transitive
    description:
      name: gql_dedupe_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.0"
  gql_error_link:
    dependency: transitive
    description:
      name: gql_error_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.0"
  gql_exec:
    dependency: transitive
    description:
      name: gql_exec
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.1-alpha+1633799193908"
  gql_http_link:
    dependency: transitive
    description:
      name: gql_http_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.0"
  gql_link:
    dependency: transitive
    description:
      name: gql_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.0"
  gql_transform_link:
    dependency: transitive
    description:
      name: gql_transform_link
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.0"
  gradient_widgets:
    dependency: "direct main"
    description:
      name: gradient_widgets
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.6.0"
  graphql:
    dependency: transitive
    description:
      name: graphql
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.0.0"
  graphql_flutter:
    dependency: "direct main"
    description:
      name: graphql_flutter
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.0.0"

If you want to dive deeper on this, refer to the file links/gql_exec/lib/src/response.dart line #27 in the following commit where the new parameter was added and declared as required. https://github.com/gql-dart/gql/commit/8699d2fcc285789ec6e891b034e98fd2b7750296#diff-99580a029d7aed82312588b8cda13419bc8f9c0e58ac97e1f7bcdad51fc39c10R27

like image 56
dakine Avatar answered Oct 18 '22 21:10

dakine