GoogleCloudPlatform / endpoints-proto-datastore

Apache License 2.0
154 stars 52 forks source link

Optional EndpointsAliasProperty #146

Closed crstian closed 7 years ago

crstian commented 7 years ago

Hey folks,

we have an issue with nested relationships. Is it possible to make an @EndpointsAliasProperty optional?

Lets say we have an endpoint which queries a list of entities. Each of the queried entity has a couple of child entities (via @EndpointsAliasProperty) which in turn also have some child entities (via @EndpointsAliasProperty).

So the problem is that the query becomes really big because each of the entities queries a bunch of child entities for themselves which is why the query takes ages to return the data (> 25 - 35 seconds). Some of the child entities are not even required in the endpoint output. However we can not remove the not required alias properties from the EndpointModel because there are other endpoints which use these entities.

I hope it is clear what I am trying to explain. Is there any way to make an @EndpointsAliasProperty optional for some queries? Or can anyone give advice?

Thank you in advance!

dhermes commented 7 years ago

I think _message_fields_schema (see) should be able to handle this for you. You could also use MyModelClass.ProtoModel(fields=(...)) to define a schema for some requests. With a custom proto model you can use @MyModelClass.method(request_message=proto_model_class).

crstian commented 7 years ago

Thanks that worked for me!

dhermes commented 7 years ago

Good to hear!