Content-Length: 385274 | pFad | https://github.com/aws/graph-explorer/pull/734

1F Improve default connection logic by kmcginnes · Pull Request #734 · aws/graph-explorer · GitHub
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

Improve default connection logic #734

Merged
merged 7 commits into from
Jan 7, 2025
Merged

Conversation

kmcginnes
Copy link
Collaborator

@kmcginnes kmcginnes commented Jan 7, 2025

Description

  • Move the code that fetches the default connection out of index.tsx and in to AppStatusLoader.
  • Add type for NeptuneServiceType
  • Add Zod schema for default connection data
    • Move default values in to Zod schema
    • Add tests
  • Use TanStack Query to fetch default connection data
  • Show loading screen while fetching default connection
  • Add tests for default connection data validation and fallback behavior

Validation

  • Verified with no default connection and empty database
  • Verified with default connection and empty database
  • Verified with default connection and existing database
  • Verified with no default connection and existing database

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0
    license.
  • I have run pnpm checks to ensure code compiles and meets standards.
  • I have run pnpm test to check if all tests are passing.
  • I have covered new added functionality with unit tests if necessary.
  • I have added an entry in the Changelog.md.

@kmcginnes kmcginnes marked this pull request as ready for review January 7, 2025 21:04
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 41.52542% with 69 lines in your changes missing coverage. Please review.

Project coverage is 19.27%. Comparing base (9d3a2b7) to head (e9f1c93).
Report is 61 commits behind head on main.

Files with missing lines Patch % Lines
...kages/graph-explorer/src/core/defaultConnection.ts 42.85% 44 Missing ⚠️
...ckages/graph-explorer/src/core/AppStatusLoader.tsx 0.00% 18 Missing ⚠️
packages/graph-explorer/src/index.tsx 0.00% 3 Missing and 1 partial ⚠️
...r/src/core/ConnectedProvider/ConnectedProvider.tsx 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
+ Coverage   14.88%   19.27%   +4.38%     
==========================================
  Files         566      532      -34     
  Lines       25121    23024    -2097     
  Branches     1170     1175       +5     
==========================================
+ Hits         3739     4437     +698     
+ Misses      21050    18319    -2731     
+ Partials      332      268      -64     
Flag Coverage Δ
unittests 19.27% <41.52%> (+4.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

expect(actual).toEqual(data);
});

test("should handle missing values", () => {

Choose a reason for hiding this comment

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

Nit: can consider adding test that invalid/unexpected values in the response result in defaults since the logic uses statements like z.string().url().catch("") and z.boolean().default(false). Ie. what happens if url is not correct format or a boolean value is 'TRUE' instead of true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test for invalid URLs. But the booleans and numbers aren't string values, so they should come in fine or the await response.json() will fail, which results in null config, which is appropriate.

I wish it was easier to mock out fetch so I could do more testing. I have a plan for mocking fetch, but it is too involved for this change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ran a test where I forced a string in to the boolean property to see what happens. It fails the Zod validator properly, but I want to improve the logging of that error. So I'm going to update the parsing logic to print out a nicer console error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the logging of parse errors

enabled: isStoreLoaded && configuration.size === 0,
});

const config = defaultConfigQuery.data;
Copy link

@andreachild andreachild Jan 7, 2025

Choose a reason for hiding this comment

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

Nit: Can config be renamed to something more descriptive as to differentiate it better from configuration? At first glance it's not clear the difference between the two.

Copy link
Collaborator Author

@kmcginnes kmcginnes Jan 7, 2025

Choose a reason for hiding this comment

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

I could, but I left it named config to match the old code to reduce the code changed.

It really should be renamed, so since you brought it up I'll make the change 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@andreachild
Copy link

LGTM

@kmcginnes kmcginnes merged commit fd38479 into aws:main Jan 7, 2025
1 check passed
@kmcginnes kmcginnes deleted the bootstrap-app branch January 7, 2025 23:22
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.

[Task] Validate default connection data Use suspense for app loading process
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/aws/graph-explorer/pull/734

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy