This could be supreme noob q, apologies.
SwiftUI ios 16 Apollo GraphlqQL1.6
Im tired and I cant work out what it wants, if I just feed it a string “skdjf” it will also not work.
I did not have this problem in graplhQL 0.5 series
let nameT = "music"
apollo.fetch(query: SchemaPPP.GetEventsByCategoryQuery(name: nameT , minTime: secTime ))...
for both arguments name, minTime i get
Cannot convert value of type ‘String’ to expected argument type ‘GraphQLNullable’
basis of my query
query GetEventsByCategory($name: String, $minTime: String) {
eventTypes(where: {name_contains: $name}) {
slug
id
name
events(where: { nextEventUTC_gt: $minTime}) {
id
guid
title
You need to pass a value of type GraphQLNullable
, e.g. .some(nameT)
. Your query would look something like:
SchemaPPP.GetEventsByCategoryQuery(name: .some(nameT) , minTime: secTime ))
I ran into the same issue migrating to v1.x and created helper class.
public struct GraphQLHelper {
@available(*, unavailable)
init() {}
/// Wraps a value inside a `GraphQLNullable` object. Use when a GraphQL property expects
/// a `GraphQLNullable` type.
///
/// - parameter value: The object to wrap
///
/// - returns: a `GraphQLNullable` object
static public func graphQLNullableFrom<T>(_ value: T?) -> GraphQLNullable<T> {
if let val = value {
return .some(val)
}
return .none
}
}
The helper can be used with Optional properties too, returning .none
when the property is nil
.
Use:
SchemaPPP.GetEventsByCategoryQuery(name: GraphQLHelper.graphQLNullableFrom(nameT) , minTime: secTime ))