I met this problem while dealing with GraphQL + Apollo. There are multiple queries that return structurally equivalent yet nominally different types. I want to handle the these polymorphically (in pseudo-rescript):
let result = switch cases {
| case1 => MyQuery.A.use(arg)
| case2 => MyQuery.B.use(arg)
}
but I can’t, as these two have different types—something like MyQuery.A.A_inner.t
and MyQuery.B.B_inner.t
. Maybe the coercion operator from v11 might help, but Apollo client bindings + graphql-ppx stack does not support v11 yet. Is Obj.magic
the only way to bypass the typechecker?