Tôi có một UserType và một userable có thể là Writer hoặc Account.Làm cách nào để chỉ định các loại đa hình với ruby-graphql?
Đối GraphQL I figured có lẽ tôi có thể sử dụng một UserableUnion như thế này:
UserableUnion = GraphQL::UnionType.define do
name "Userable"
description "Account or Writer object"
possible_types [WriterType, AccountType]
end
và sau đó xác định loại người dùng của tôi như thế này:
UserType = GraphQL::ObjectType.define do
name "User"
description "A user object"
field :id, !types.ID
field :userable, UserableUnion
end
Nhưng tôi nhận được schema contains Interfaces or Unions, so you must define a 'resolve_type (obj, ctx) -> { ... }' function
Tôi đã cố gắng đặt một resolve_type ở nhiều nơi, nhưng tôi không thể hình dung điều này?
Hiện tại có ai thực hiện việc này không?