Skip to content

Invoking Query.Data(jsonObject:) fails for queries with params #435

@diegorozen

Description

@diegorozen

Following #51, I am trying to create a GraphQLSelectionSet via init(jsonObject: JSONObject)

The query I'm testing has a non-optional parameter 'Episode'

query Hero($episode: Episode, $withFriends: Boolean!) {
hero(episode: $episode) {
name
friends @include(if: $withFriends) {
name
}
}
}

and to JsonObject I'm passing is

{
"data": {
"hero": {
"__typename": "Droid",
"name": "R2-D2",
"friends": [{
"__typename": "Human",
"name": "Luke Skywalker"
}, {
"__typename": "Human",
"name": "Han Solo"
}, {
"__typename": "Human",
"name": "Leia Organa"
}]
}
}
}

The call fails in GraphQLExecutor.swift

throw GraphQLError("Variable \(booleanCondition.variableName) was not provided.")

The error is "Variable withFriends was not provided". The variable info: GraphQLResolveInfo was never populated because the init method calls executor.execute without specifying the variables field, which is nil by default.

Should we skip validation of input parameters when calling this method? If so, which would be the recommended way?

Thanks,
Diego

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions