-
Notifications
You must be signed in to change notification settings - Fork 52
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
Cannot access subresources in generated javascript client without top-level getter. (was: How to use nested api with javascript client?) #96
Comments
Off the top of my head, I think it depends on how you defined your resource. If it has a named identifier, it should be something like |
@hesselink I use
|
That's strange. I just tested with an |
Sure.
TopLevel schema and nested Schema respectively looks like this:
So, to summarize, my api is running at
|
Sorry for not coming back to you sooner. I changed one of the endpoints (
I could then run the following code from node, and get a result:
So that clears up the javascript API. The question is why it doesn't work for you. Perhaps you haven't defined a getter? The If that's not it, I'm not sure what else to do. Perhaps you could provide a complete example that doesn't work, that I can compile and run? |
Looking at your code again, I think |
|
Could you see if that fixes the issue? |
My reasoning is that in |
|
What is the reasoning behind that? Are you trying to verify that the resource with such id exist before allowing the user to call the nested apis? In my opinion, the user should be allowed to access all the nested resources despite the fact that the |
Ah, so if I understand correctly, if you have a resource without a getter, you cannot access any subresources using the generated Javascript client? Is that correct? That does sound like a bug. |
Yes, you can reproduce the behaviour on the |
(As an aside, I'm having trouble seeing how you would use this in the real world: if you do have a listing, then you might as well have a single getter. If you don't have a listing, how will a user know which resources exist?) |
I was actually planning to add the the single getter in future, so knowing that adding the getter would fix the problem would be sufficient for me, that's right. |
Great, then I'll leave this one open to fix it eventually. Thanks for helping figure this one out! |
You also cannot remove a resources that doesn't have a getter. |
What do you mean exactly? Remove what? The subresource or the resource itself? And in the API, or only in the generated javascript? |
You cannot remove the resource itself with the generated JS. Haskell client is ok. It generates e.g. |
Hi,
it's not clear for me, how to use the javascript generated client with a nested resource. Calling the top-level is easy:
How do I call the nested resource?
Let's say I have this schema
/toplevel/<id>/resource/
.Calling that resource with curl, for example
/api/v1.0.0/toplevel/5/resource/
works, but I don't know how to call it with the generated client. This code doesn't work:Any help appreciated :-)
The text was updated successfully, but these errors were encountered: