swift-graphql icon indicating copy to clipboard operation
swift-graphql copied to clipboard

using args causes error in response

Open atomkirk opened this issue 1 year ago • 2 comments

Describe the bug When I pass optional arguments, the server gets the right params and returns a valid response, but the library fails to parse it. If i return the exact same response from the srerver with the optional arguments removed, it parses it fine.

To Reproduce I've got these queries:

  static func upcoming(search: String?) -> Selection.RootQueryType<[Meeting]> {
    Selection.RootQueryType<[Meeting]> {
      try $0.meetings(
        filters: ~InputObjects.MeetingFilters(after: ~Meeting.nowString(), search: ~search),
        sort: ~[
          InputObjects.MeetingSort(
            direction: Enums.SortDirection.asc, field: Enums.MeetingSortOption.startedAt)
        ],
        selection: selection.list
      )
    }
  }

i return this json from the server:

          [
            {
              "id": "int_ref_067dfc66bc9146e0a6a",
              "status": null,
              "started_at": "2013-12-09 18:00:00Z",
              "participants": [],
              "topic": "Lunch",
              "conference_url": null,
              "task_count": 0
            },
            {
              "id": "int_ref_2c8a9d4f4e60491187a",
              "status": null,
              "started_at": "2013-12-11 01:00:00Z",
              "participants": [],
              "topic": "Take down Nativity",
              "conference_url": null,
              "task_count": 0
            }
          ]

if I remove after: ~Meeting.nowString(), it works, parses the two rows and displays in my UI. If I include it and the server returns the exact same thing, it fails to parse it.

It's weird that passing an arg would affect how it parses the response. I dont see why those would be connected, but they must be.

I'm using the latest version, latest xcode, etc.

atomkirk avatar Jan 16 '24 20:01 atomkirk

I would dive in and try to fix myself but I don't know swift well enough. I'd pay a $200 bounty for anyone who can fix quickly.

atomkirk avatar Jan 16 '24 20:01 atomkirk

I'll take a look tomorrow morning, I'm need to re-read this but its late atm for me, so let me check one this in the morning 👍

shaps80 avatar Jan 16 '24 22:01 shaps80