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

[EASI-4457] TRB Request Funding Sources dataloader #2715

Merged

Conversation

mynar7
Copy link
Contributor

@mynar7 mynar7 commented Jul 22, 2024

EASI-4457

Description

  • Add dataloader for TRB Request Funding Sources

How to test this change

  • Query for form/fundingSources on TRB Requests.

PR Author Checklist

  • I have provided a detailed description of the changes in this PR.
  • I have provided clear instructions on how to test the changes in this PR.
  • I have updated tests or written new tests as appropriate in this PR.

PR Reviewer Guidelines

  • It's best to pull the branch locally and test it, rather than just looking at the code online!
  • When approving a PR, provide a reason why you're approving it
    • e.g. "Approving because I tested it locally and all functionality works as expected"
    • e.g. "Approving because the change is simple and matches the Figma design"
  • Don't be afraid to leave comments or ask questions, especially if you don't understand why something was done! (This is often a great time to suggest code comments or documentation updates)
  • Check that all code is adequately covered by tests - if it isn't feel free to suggest the addition of tests.

@mynar7 mynar7 requested review from a team and samoddball and removed request for a team July 22, 2024 22:49
@mynar7 mynar7 requested a review from a team as a code owner July 22, 2024 22:49
// should have no sources initially
s.Len(fetched, 0)
// current GQL schema returns null instead of an empty array for no funding sources
s.Nil(fetched)
Copy link
Contributor Author

@mynar7 mynar7 Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the previous version of the tests worked with NotNil, but the schema dictates a null return and that causes the resolver to pass nil instead of an empty slice. The functions return empty slices as they should, so I'm confused why it's returning [] instead of null on the main branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After local testing to double check this, it appears we're returning an empty slice currently despite the schema saying it's possible we can return nil. I went ahead and fixed this test to allow for an empty slice or nil here: a8ecd66

The front-end is already typed for null or [], so actually returning null like the schema specifies shouldn't be an issue. I also tested the FE locally to double check this assumption and didn't see any issues.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this might be a good spot to just add a TODO comment in the gql schema to make the array non-nullable -- I would expect the schema to define:

# This
fundingSources: [TRBFundingSource!]!
# Instead of this, which is our current schema:
fundingSources: [TRBFundingSource!]

@mynar7 mynar7 requested a review from ClayBenson94 July 23, 2024 13:14
@StevenWadeOddball StevenWadeOddball removed the request for review from a team July 23, 2024 15:21
Copy link
Collaborator

@ClayBenson94 ClayBenson94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving -- all the changes seem in line with what I'd expect for dataloading this resource!

(I left a comment suggesting a TODO comment in the schema, but not going to have that hold an approval!)

if err != nil {
appcontext.ZLogger(ctx).Error(
"Failed to fetch TRB request funding sources",
zap.Error(err),
zap.String("trbRequestID", trbRequestID.String()),
)
return nil, err
return nil, &apperrors.QueryError{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we aiming to get rid of all the apperrors stuff? i was under the impression it's a tech-debt goal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad -- didn't catch this 🤦

I noted in Slack, but for posterity I will share my thoughts here as well!

I think I typically would prefer standard go errors rather than trying to (or having to...) wrap errors all the time. Perhaps we could take a look at customizing error types in some other way, but I'd be good to move in the direction away from these error types!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't hold up a PR for it because they're not really harmful, but maybe we could rip them out of the codebase at some point!

@mynar7 mynar7 requested a review from a team as a code owner July 26, 2024 19:32
@mynar7 mynar7 requested review from aterstriep and removed request for a team July 26, 2024 19:32
@mynar7 mynar7 merged commit 1bf2dd2 into feature/EASI-4457 Jul 29, 2024
12 checks passed
@mynar7 mynar7 deleted the EASI-4457/trb-request-funding-sources-dataloader branch July 29, 2024 13:35
mynar7 added a commit that referenced this pull request Aug 1, 2024
* [EASI-4457] Funding sources dataloader and mapper refactor (#2692)

* add funding source dataloader and refactor helpers.OneToMany and Mapper interface

* fix store method, call dataloader version in resolver

* [EASI-4457] Add dataloader to TRB request form resolver (#2695)

add dataloader to trb request form resolver

* [EASI-4457] System intake notes dataloader (#2693)

update notes resolver to use dataloader, add tests for notes

* [EASI-4457] System Intake Actions dataloader (#2694)

add dataloader to system intake actions resolver

* [EASI 4457] - TRB Request Feedback dataloaders (#2700)

* add dataloaders to TRB Feedback

* convert slice to postgres array

* use dataloaders in status calls

* remove unnecessary no rows error check

* [EASI-4457] TRB Advice letter dataloader (#2702)

* add dataloaders to TRB Feedback

* convert slice to postgres array

* use dataloaders in status calls

* remove unnecessary no rows error check

* add dataloaders to advice letter and finish refactoring statuses

* sort mock users

* nil check statuses

* [EASI-4457] TRB attendees dataloaders (#2705)

* add dataloader to trb attendees

* add dataloader for attendees by EUA and TRB ID, update requester component resolver

* use ptr helper, add to resolver test

* [EASI-4457] Add closed requests for testing (#2709)

* refactor seed data to allow for closed request generation

* remove context value and just use a constant

* add regex to LCID test

* [EASI-4457] TRB documents dataloaders (#2706)

* add a dataloader for trb documents, use dataloaders in other resolvers

* semicolons and better error handling

* [EASI-4457] TRB Admin Notes dataloader (#2714)

add dataloaders for TRB admin notes

* [EASI-4457] TRB Request Funding Sources dataloader (#2715)

* add dataloader for trb funding sources

* fix test to allow for empty slice

* add TODO comment

* [EASI-4457] TRB Form System Intakes dataloader (#2722)

add dataloader for trb request form system intakes

* [EASI-4457] Add gov req feedback dataloader (#2731)

* add gov req feedback dataloader

* run gql gen

* [EASI-4457] intake documents dataloader (#2732)

* add dataloader for documents

* use resolver to create fake documents

* update seed script

* update seed script to not fetch users multiple times for closed requests

* add comments

* [EASI-4457] Business Case dataloaders (#2729)

* refactor business case legacy code to allow for biz case and cost line dataloaders with less friction

* cleanup comments

---------

Co-authored-by: samoddball <156127704+samoddball@users.noreply.github.com>

---------

Co-authored-by: samoddball <156127704+samoddball@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants