-
-
Notifications
You must be signed in to change notification settings - Fork 206
[ParseCloudFunction] Unhandled exception: type 'ParseObject' is not a subtype of type 'DietPlan' in type cast #28
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
Comments
Actually, thinking back, I'm not sure that this would work. There's no way for the function to know that you are working with DietPlans... I'm not sure what the default functionality for this should be. Should it recognise that it's a DietPlan, or would it always recognise it as a ParseObject? |
I copy/pasted the updated example
I know, I test with two cloud code functions, the first which returns one object, And I test a second CC function which returns multiple objects and the error was :
Sorry but I didn't understand :/ |
Okay, for a function result to be recognised as a custom class, your DietPlan would extend function, instead of ParseObject. The only other way you can do this is to create a method inside DietPlan, that converts a ParseObject to a DietPlan. i.e.:-
Or maybe something like inside DietPlan:-
With regards to the 'ParseObject' is not a subtype of 'Iterable', it's because that is a list of ParseObjects, not a single object. You would need to create something like:-
Then using the method above, in DietPlan:-
|
Closing issue. Please reopen if not resolved |
Hi, I don't know how to reopen the issue but there is now an other problem. I created a Cloud Code function which returns only one object (Web), this is my code :: web.dart
In my main.dart:
But after the print, in my console :
The problem is that my Web object si almost empty, there is only the className but no other infos like the slogan (string in my object). Do you have an idea ? In advance, thank you. |
Hey, It looks to me that the object you are sending yourself from your Cloud Function is the issue. The payload print statement in the ParseResult item is simple the response we receive from the server. It doesn't look like you are actually sending the correct object in your Cloud Function.... I think anyway? I'm not an expert in the Cloud Function area in all honesty, but judging by your response, that suggests to me that your not sending the correct object. |
Yes I'm sending the correct object but I couldn't say what's the problem in the SDK. Maybe you can test it on your side with a basic cloud coud function which just returns the first object. |
Sorry, I think you misunderstood...
is what the server is sending back, that's it. There's no more information for the SDK to work with. That is a reference to an object, but not an object itself. If this is the standard behaviour on the Android SDK or iOS SDK then I would have to implement another query based on this. For example,
Your cloud function is only sending a pointer, rather than the full object itself. |
I understand what you say but, see my logs from Parse : (don't worry if it's no more a Web object but a News object, I'm making some test)
And see my console :
|
I see, I'm still a bit confused though. What happens if you breakpoint the ParseResponse object. What does the ParseResponse.result object contain? |
My code
Console:
|
Okay, so yeah... I was correct above in saying the object has not been received. Only a pointer to the object has been received? |
It looks like yes but the cloud code function returns an object and not a pointer (we can see it in the logs) :/ |
Which logs does it show an object, in the Cloud Function? |
Yes
|
Okay, so that's still technically correct. The SDK is only printing what is received from the server... Which technically is the object, but not all the object data. It's only sending a reference to that object which you can obtain as you have the objectId. The SDK is only printing in payload, exactly what it receives from the server, no more and no less. |
Ok I understand but what is the solution ? Is that the SDK should made a query for each object (with its objectId) and store all complete objects in a list ? |
Correct. The cloud function should send a list of pointers (so that the payload is very minimal) and then the SDK should make requests for more information as per the example I gave above. this is the most efficient way to do what you are trying to achieve. |
Ok so I imagine that it's a feature which will be implemented later in the sdk ? |
No. That's not a function the SDK should handle. That should be the implementation of the SDK. |
Sorry for my bad english but I don't understand. My question would be rather: Have I to handle this "problem" like I say :
Or later, the SDK will be able to manage this ? PS: I take this opportunity to thank you Phill Wiggins for your work for the moment and I can't wait to see the Flutter Parse SDK evolve in the future. 🥇 |
I think that it's something we could look at in the future, but for now there are more urgent features that need developing. Right now, if I was you, I would just make a query using the objectId's provided from your cloud function. I hope that helps and your very welcome! |
Hello,
I created a Cloud Code Function which returns only one Diet_Plans object.
I execute this code :
And there is an error with the print in the success condition, this is my console :
And similar error when the cloud code function return multiple objects, there is an error like :
In advance, thank you.
The text was updated successfully, but these errors were encountered: