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

feat: Use standardized gql fragments in queries.js files #1147

Merged
merged 49 commits into from
Jul 31, 2024

Conversation

howard-e
Copy link
Contributor

@howard-e howard-e commented Jul 8, 2024

To supersede #876.

I've deviated from the original suggestion of:

I'm down with this. Most fields don't impact query performance so it's totally fine to just query all of them every time. For fields that do impact performance, like tests on TestPlanVersions and testResults on TestPlanRuns, I think it should be divided into two fragments to make accidentally tanking your performance less likely to happen. Something like TEST_PLAN_RUN_FIELDS and TEST_PLAN_RUN_TEST_RESULTS_FIELDS.

I think fields like renderableContent might be preferable to leave off, since they're extremely verbose and "specialty" for specific use cases. If it's there where it's not needed it will definitely make debugging responses harder.

We can manually add them where they're needed.

Mainly because having significantly populated queries per page even if the performance hit was marginal (significant in some cases) became somewhat noisy.

So I did my best to identify common enough existing attributes being requested per page and included them in their own respective client/components/common/fragments/TYPE.js file. Where applicable, I created 2 separate queries for the graphql type (simple and all).

Another oddity about this work is there is an inconsistency between the testPlanVersionResolver and testPlanVersionsResolver which makes using the ...TestPlanVersion fragment throw errors for some queries. It may not be worth resolving now due to the current size of the PR and could be follow up task if it becomes an issue.

This PR is still missing several tests for components to feel confidence in this change, but I would rather not balloon this PR more. In discussing this with @stalgiag, they noted that the missing tests can be done in a follow up PR. So this shouldn't be merged until that work is done (so leaving as draft for now).

# Conflicts:
#	client/components/TestQueue2/queries.js
# Conflicts:
#	client/components/TestQueue/queries.js
…move as there's an issue with testing the loading element in 'e2e' test)
# Conflicts:
#	client/components/DataManagement/queries.js
#	client/components/TestQueue/queries.js
#	client/tests/__mocks__/GraphQLMocks/DataManagementPagePopulatedMock.js
# Conflicts:
#	client/tests/DataManagement.test.jsx
@howard-e howard-e changed the title wip: Use standardized gql fragments in queries.js files Use standardized gql fragments in queries.js files Jul 22, 2024
Copy link
Contributor

@stalgiag stalgiag left a comment

Choose a reason for hiding this comment

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

Very impressed you managed to change this much in place. I gave cross verification between the fragments and the old queries my best shot but obviously there are limits on what a human can accomplish there. As such, I agree that we are going to need additional testing to feel secure here.

For the purposes of this PR as it stands and how it will guide additional work before merging, I like where you drew the boundaries on the fragments. You've struck a good balance between reusability with a limited set of fragments and precision of fetch. Also all of the non-query updates make sense to me including the changes in the testing.

I will wait to mark this approved until we get the additional PRs in but for the purposes of continuing this work, I approve this. I'll reach out to you directly to coordinate writing additional tests.

# Conflicts:
#	client/tests/DataManagement.test.jsx
#	client/tests/__mocks__/GraphQLMocks/DataManagementPagePopulatedMock.js
#	client/tests/e2e/Reports.e2e.test.js
#	client/tests/e2e/TestPlanVersions.e2e.test.js
#	client/tests/e2e/TestReview.e2e.test.js
#	client/tests/e2e/TestRun.e2e.test.js
@howard-e howard-e changed the title Use standardized gql fragments in queries.js files feat: Use standardized gql fragments in queries.js files Jul 29, 2024
@howard-e howard-e marked this pull request as ready for review July 29, 2024 21:17
@howard-e howard-e requested a review from stalgiag July 29, 2024 21:17
Copy link
Contributor

@stalgiag stalgiag left a comment

Choose a reason for hiding this comment

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

Looks good to me! As I said earlier, I like where the boundaries were drawn and a fragment for TestPlanVersion can be a low priority follow-up.

I am amazed that it passes the new tests on the first try. Well done!

@stalgiag stalgiag merged commit dd4b8c2 into development Jul 31, 2024
2 checks passed
@stalgiag stalgiag deleted the use-gql-fragments branch July 31, 2024 19:54
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.

2 participants