graphql-perl / GraphQL-Plugin-Convert-DBIC

Plugin to convert DBIx::Class schema to GraphQL schema
https://metacpan.org/release/GraphQL-Plugin-Convert-DBIC
4 stars 5 forks source link

Query fetches too many columns #21

Open schroeer opened 4 years ago

schroeer commented 4 years ago

The query resolver always selects all columns of all involved tables, even if only a few fields (columns) are selected. This might be a problem if some columns contain very much data.

mohawk2 commented 4 years ago

Quite right, and being selective about what to extract is one of the points of GraphQL. Feel like making a PR to fix this? I think it'd just take adding some args to the various calls to find and search, constructing which fields to get from $info->{field_nodes}.

schroeer commented 4 years ago

What makes this a little bit hairy is that you need to keep track of the table aliases (see here). GraphQL does not prevent you from joining the same table more than once.

mohawk2 commented 4 years ago

That's true! And we could use the given alias as the table alias in some fashion. Some properly tortuous examples will be needed to check this is correct.

schroeer commented 4 years ago

Unfortunately, you cannot control the aliases that DBIC uses. So you'll have to copy what DBIC does.