lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Fix rehydration of subscription args with differing internal representations

Open spawnia opened this issue 4 years ago • 5 comments

  • [x] Added or updated tests
  • [ ] Documented user facing changes
  • [ ] Updated CHANGELOG.md

Changes

Breaking changes

spawnia avatar Jun 11 '20 13:06 spawnia

@stayallive opened the PR to see the results of the test run.

spawnia avatar Jun 11 '20 13:06 spawnia

That's a tricky one.

We currently store the internal value of the ENUM when serializing the subscription, which causes the rehydrated execution during the broadcast to fail. This might also be problematic when using custom scalar types whose internal representation might not be serializable.

I think we should try and get a hold of the raw args/variables that are passed during the initial subscription request and serialize exactly those. That will ensure the rehydrated requests function exactly the same.

spawnia avatar Jun 14 '20 13:06 spawnia

Yeah was thinking the same, will brew a bit on this, thanks for the pointers 👍

stayallive avatar Jun 15 '20 07:06 stayallive

That prettify docs shouldn't have ran here and or had any effect... that will mess up some PR's 😉

stayallive avatar Aug 25 '20 19:08 stayallive

@stayallive a tricky part is that the raw request may contain literal argument values as well as variables. We don't ever see an intermediary representation where those are merged, but not cast to their internal values (e.g. Enum classes).

I dug in to graphql-php and see if they expose this structure, or at least a method to build it from the raw request. Looks like there is no representation of raw, merged arguments: https://github.com/webonyx/graphql-php/blob/4f3430990824ff410fe548102cb85f0c46442704/src/Executor/ReferenceExecutor.php#L623-L627

spawnia avatar Aug 27 '20 06:08 spawnia