micronaut-projects / micronaut-projects/micronaut-data

Query projection with multiple fields on runtime

Open
#905 0 comments 3 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Java
Stars
482
Forks
229
Avg merge
1d 7h
Merged PRs (30d)
32

Description

Hi

I think it would be very helpful to be able to give a list of field names at runtime for projection instead of fully typed DTOs. Especially for incoming requests from GraphQL it seams very useful to only request fields from the database which will be returned to client.

The syntax could be (similiar to those of [Query Projections](https://micronaut-projects.github.io/micronaut-data/latest/guide/#projections)):
`Map findFieldsById(List fields, int id)`

So every time where on `find` follows `Fields` (or after `findDistinct`, `get`, etc.) and the return type is out of a `Map`, the first argument shall be a list of field names (or alternatively a list of reflection's `Field`, if this would easier to provide).

I think this could be used for flexible projection for all database types easily e.g. relational, document, graph, Cassandra etc.

Elsewise the whole dataset needs to be requested from the database, all fields need to be parsed into the models, but won't be used for further processing by GraphQL, which seams senseless.

Thank you in advance.
Looking forward to your feedback.

Kind regards.
Ramazan

Contributor guide

Open the contributing guide

Research direction

Start with the Query Projections guide linked in the issue and review how repository projection methods are currently defined. Determine the scope needed for runtime field lists and map results across the supported database types; done means the proposal has a concrete API, implementation boundaries, and coverage expectations.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.