0
Ich folge haben diese docs über Schnittstelle auf graphql erstellen und implementieren:Graphql Rubin, wie Interface-Typ erstellen und implementieren es
hier ist mein Code:
PaymentInterface = GraphQL::InterfaceType.define do
name 'Payment'
field :name, types.String
field :grand_total, MoneyType
field :subtotal, MoneyType
field :shipping_fee, MoneyType
end
und dies ist der Objekttyp, vorherige Schnittstelle implementieren
PaypalPaymentType = GraphQL::ObjectType.define do
interfaces [PaymentInterface]
field :paypal_charge do
type -> { MoneyType }
type types.String
resolve lambda { |obj, _args, _ctx|
Hashie::Mash.new(
currency: obj.currency,
price: obj.paypal_charge
)
}
end
end
Hier ist die Abfrage:
interface PaymentInterface {
name: String
grand_total: MoneyType
subtotal: MoneyType
shipping_fee: MoneyType
}
type PaypalPaymentType implements PaymentInterface {
name: String
grand_total: MoneyType
subtotal: MoneyType
shipping_fee: MoneyType
paypal_charge: MoneyType
}
{
purchasables {
isService
isProduct
price
... on PaypalPaymentType {
paypal_charge { raw formatted }
}
}
}
Aber ich bekomme immer Fehler, hat jemand die gleiche Erfahrung vor? Vielen Dank im Voraus
GraphQL::Schema::InvalidTypeError (Field PaymentMethod.paypal_charge is invalid: name must return String, not NilClass (nil)):
Welche Art von Fehler ist es, dass Sie bekommen? – tpei
@tpei aktualisiert meine Frage –