-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getting "Cannot complete value of unexpected type X" error with children #10
Comments
I accidentally created the issue before I described the problem, fixed now. Sorry about that. |
I haven't had this issue before. Bug I could reproduce it (The example repo was very handy!) and I fixed it. |
Thanks! I’m away from my office for a few days, but I’ll check it out when I get back on Monday.
… On Aug 26, 2021, at 6:41 AM, Alexander Steiner ***@***.***> wrote:
I haven't had this issue before. Bug I could reproduce it (The example repo was very handy!) and I fixed it.
This GraphQL Swift api is a bit confusing.
By using the Order type in the query this type is registered automatically (implicitly).
The type OrderItem is not implicitly registered.
You can explicitly register the type OrderItem by adding this line to the bottom of your schema: Types(OrderItem.self) (Example: https://github.com/GraphQLSwift/Graphiti/blob/af903a243862c6427935677b91f67df0c21f2a71/Tests/GraphitiTests/StarWarsAPI/StarWarsAPI.swift#L101).
I hope this can help you.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Sure enough, that completely fixes it. Although I can't say that I understand fully why. It seems like there's a very explicit registration of the Really appreciate the help, as always. |
I agree, this doesn't seem perfect from an API perspective. But I also don't know enough about the Graphiti implementation so I can't explain the reason for this. |
I'm having trouble resolving the children of a model. I definitely might be doing something super dumb though. What's odd is, in my other vapor/graphql app (yes, I have two now...) I haven't hit this problem, but I use parent/children a decent bit. Anyway, I have models like this:
The schema looks like this:
And the resolver looks like this:
But when I send a graphql query like so:
I get the error
Cannot complete value of unexpected type \"OrderItem\".
I feel like I'm missing something stupid. I think I'm sort of following your examples for users/todos in the readme.
If the code above isn't clear enough, I've created a super minimal reproduction repository using an in-memory sql-lite db. If you want to take a look, you can just clone the repo, then run
swift run
and (in another terminal tab) trybash ./test-error.sh
to send the query shown above.The text was updated successfully, but these errors were encountered: