Skip to content

Assert when comparing two results of a query #3593

@PatrickDanino

Description

@PatrickDanino

Summary

We use various queries that include @skip and @include directives. We use equality to check if our state has changed.

From what I can tell, the result of one of our queries is crashing due to an equality check failing when comparing it to the previous value.

It's not clear to me if this is by design or not given the assert message. If it is, it would be helpful to know why fragments are required.

The stack is as follows:

#6	0x0000000110a1abf0 in SelectionSet.addConditionalSelections(_:to:) at .../Sources/ApolloAPI/SelectionSet+Equatable.swift:141
#7	0x0000000110a1a570 in SelectionSet.addFulfilledSelections(of:to:) at .../Sources/ApolloAPI/SelectionSet+Equatable.swift:52
#8	0x0000000110a1a068 in SelectionSet.fieldsForEquality() at .../Sources/ApolloAPI/SelectionSet+Equatable.swift:29
#9	0x0000000110a1a140 in static SelectionSet.== infix(_:_:) at .../Sources/ApolloAPI/SelectionSet+Equatable.swift:18

This line is being hit:

assertionFailure("Conditional selections should not directly include fields. They should use an InlineFragment instead.")

Version

2.0

Steps to reproduce the behavior

  • Define a query that uses conditional fields gated by @skip and/or @include (i.e. conditionalValue @skip(if: $condition) { field }
  • Load the results of the query
  • Load the results of a second query, changing the value of the @Skip as an example
  • Use equality to compare the two results

Logs

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions