apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.87k stars 717 forks source link

Cannot convert value of type 'GraphQLNullable<[String]>' to expected argument type '[String?]' #3340

Closed Spatel91111 closed 6 months ago

Spatel91111 commented 7 months ago

Question

If I used [String?] array with GraphQLNullable then it's passed request value like some([Optional("black")]) and that create issue I want to pass value some(["black", "black1"]) like this. How to remove GraphQLNullable<[String?]> and used GraphQLNullable<[String]>

calvincestari commented 7 months ago

GraphQLNullable is used for input types, so the field on the input type in your schema is probably [String] and not [String!].

Spatel91111 commented 7 months ago

Hello @calvincestari , yes I have used status: [String] in schema but still getting issue

calvincestari commented 7 months ago

Create a sample app demonstrating the problem that we can look at please.

Spatel91111 commented 7 months ago

Hello @calvincestari

Schema

Screenshot 2024-02-20 at 11 15 58 AM

code

Screenshot 2024-02-20 at 11 16 16 AM
calvincestari commented 7 months ago

In the schema screenshot, flight_type: [String] is a list of nullable strings. That is correctly generated into Swift as GraphQLNullable<[String?]>. There is nothing wrong here.

flightTypeArray3 must be the same type (GraphQLNullable<[String?]>) if you want to assign it.

Spatel91111 commented 7 months ago

Hello @calvincestari ,

If I used type (GraphQLNullable<[String?]>) then it's pass input value like [Optional("black")]

Spatel91111 commented 7 months ago

@calvincestari , is there any way to configure the file to add any setting value handle automatically?, then let me know.

calvincestari commented 7 months ago

If I used type (GraphQLNullable<[String?]>) then it's pass input value like [Optional("black")]

Is the JSON actually getting sent like that or only when you print it to the debug console?

is there any way to configure the file to add any setting value handle automatically?, then let me know.

I don't understand your question. A setting to handle what value? It is String? because that's what the type is in your schema.

AnthonyMDev commented 6 months ago

I'm closing this issue due to inactivity. If this is still unresolved, feel free to provide more information and we can re-open this, or create a new issue.

github-actions[bot] commented 6 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.