Skip to content
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

Selector layer questions #65

Open
mateuszzw opened this issue May 26, 2022 · 3 comments
Open

Selector layer questions #65

mateuszzw opened this issue May 26, 2022 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@mateuszzw
Copy link

Hi @ImJohnMDaniel @stohn777 ,

I would like to ask about 2 functionalities that I tried to use, but I couldn't find the built-in solution:

  1. Aggregate Queries - is there any way to do that within the selector layer without direct/dynamic queries? I found the information that it's one of the limitations of the AT4DX, but I'd like to know whether there was any specific reason it's not implemented.
  2. Polymorphic fields TYPEOF clause - it's available since API 46.0, but I couldn't find any built-in solution to use it with query factory. Are there any plans to implement it?

I really appreciate all the work you've been doing with AT4DX!

Best regards,
Matt

@ImJohnMDaniel ImJohnMDaniel self-assigned this May 26, 2022
@ImJohnMDaniel ImJohnMDaniel added the question Further information is requested label May 26, 2022
@ImJohnMDaniel
Copy link
Collaborator

G'day @mateuszzw, thanks for reaching out.

Regarding your questions:

Aggregate Queries - is there any way to do that within the selector layer without direct/dynamic queries? I found the information that it's one of the limitations of the AT4DX, but I'd like to know whether there was any specific reason it's not implemented.

  • Just to be clear, the Selector Pattern is part of the FFLIB Apex Commons framework and not part of AT4DX per se.
  • In the Apex Commons framework, the Selector Pattern builds standard queries using the fflib_QueryFactory. The query factory though does not build aggregate queries.
  • In general, when there is an Aggregate Query requirement, it is general practice to code the inline query directly in a selector class method. This way, you are still able to centralize the queries on the Sobject in its selector class.

Polymorphic fields TYPEOF clause - it's available since API 46.0, but I couldn't find any built-in solution to use it with query factory. Are there any plans to implement it?

  • As far as I know, we have not had a request for support of TYPEOF. It would be an interesting challenge to implement in the query factory. I would have to give it some more thought though. I would recommend opening a feature request over on the FFLIB Apex Commons project so that the request is at least documented. No promises on when it will happen though. Having said that, we certainly welcome if you would like to make an attempt to add that feature to the query factory.

I hope this help.

@mateuszzw
Copy link
Author

Hi @ImJohnMDaniel,

Thank you for your time on this topic!
I just wanted to elaborate my view on these matters:

In general, when there is an Aggregate Query requirement, it is general practice to code the inline query directly in a selector class method. This way, you are still able to centralize the queries on the Sobject in its selector class.

I'm aware that it's a part of the Apex Commons framework, however I just don't find it elegant to have a builder pattern used for "regular" queries, but have inline query for aggregate ones. I just thought that it would be nice to have some sort of AggregateQueryFactory that would extend the fflib_QueryFactory.

As far as I know, we have not had a request for support of TYPEOF. It would be an interesting challenge to implement in the query factory. I would have to give it some more thought though. I would recommend opening a feature request over on the FFLIB Apex Commons project so that the request is at least documented. No promises on when it will happen though. Having said that, we certainly welcome if you would like to make an attempt to add that feature to the query factory.

I'll speak with one of my colleagues as we actually thought of implementing it ourselves.

@ImJohnMDaniel
Copy link
Collaborator

@mateuszzw --

re: Your comment about a potential AggregateQueryFactory is definitely a good idea. There just hasn't been enough of a need for such a factory for someone to actually create it. Having said that, if you are interest, please feel free to make an attempt and open a PR when you feel you are ready.

re: TYPEOF -- Again, if you have an idea about how to implement, we would love to see a PR with addition when you get a chance.

Thanks for the questions. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants