vendrinc / elm-gql

https://www.npmjs.com/package/elm-gql
BSD 3-Clause "New" or "Revised" License
68 stars 13 forks source link

Field ordering in nested fragments affects response decoding #24

Open eliscie opened 1 year ago

eliscie commented 1 year ago

Hello!

Decoders generated by elm-gql seem to swap fields around if the fragment is nested alongside other fields.

Affected query:

query TestBuses {
  buses {
    id
    name
    rows
    seats {
      front
      ...SideSeats
      back
    }
  }
}

fragment SideSeats on Seats {
  rightRow # changed order! 
  leftRow
}

The query executed in the GraphiQL tool is fine: Screenshot of graphiql.html

elm-gql-decoded query, unfortunately, is not: Screenshot of index.html

However, a similar query (third column in the screenshot above), in which the fragment is not used alongside other fields, gets decoded correctly.

GitHub repository with issue reproduction: https://github.com/eliscie/city-parking My original message on the Incremental Elm Discord server: https://discord.com/channels/534524278847045633/1018161791152431234/1063527955751506070 Possibly related message on the same server: https://discord.com/channels/534524278847045633/1018161791152431234/1048392743573008416

Thank you for making elm-gql.

PsyfireX commented 1 year ago

I also encountered this bug. I had to "flatten" a lot of my fragments, otherwise the decoders would have fields in the wrong order.