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: GraphQL fragments #3066

Merged
merged 4 commits into from
Sep 25, 2024
Merged

Conversation

nasdf
Copy link
Member

@nasdf nasdf commented Sep 24, 2024

Relevant issue(s)

Resolves #3047

Description

This PR enables support for GraphQL fragments.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Added integration tests

Specify the platform(s) on which this was tested:

  • MacOS

@nasdf nasdf added feature New feature or request area/query Related to the query component labels Sep 24, 2024
@nasdf nasdf added this to the DefraDB v0.14 milestone Sep 24, 2024
@nasdf nasdf self-assigned this Sep 24, 2024
@nasdf nasdf requested a review from a team September 24, 2024 17:47
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 85.45455% with 8 lines in your changes missing coverage. Please review.

Project coverage is 79.45%. Comparing base (8dae109) to head (b49a00a).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
internal/request/graphql/parser/request.go 74.19% 4 Missing and 4 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3066      +/-   ##
===========================================
+ Coverage    79.40%   79.45%   +0.05%     
===========================================
  Files          345      345              
  Lines        26534    26557      +23     
===========================================
+ Hits         21068    21100      +32     
+ Misses        3948     3942       -6     
+ Partials      1518     1515       -3     
Flag Coverage Δ
all-tests 79.45% <85.45%> (+0.05%) ⬆️

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

Files with missing lines Coverage Δ
internal/request/graphql/parser/mutation.go 85.92% <100.00%> (ø)
internal/request/graphql/parser/query.go 90.86% <100.00%> (ø)
internal/request/graphql/parser/subscription.go 79.31% <100.00%> (ø)
internal/request/graphql/parser/request.go 72.34% <74.19%> (-1.39%) ⬇️

... and 13 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8dae109...b49a00a. Read the comment docs.

@jsimnz
Copy link
Member

jsimnz commented Sep 24, 2024

Reviewed but have a question. Should we also be supporting inline fragments? https://spec.graphql.org/October2021/#sec-Inline-Fragments

Fragments also support variables, if we want to support that too

@nasdf
Copy link
Member Author

nasdf commented Sep 24, 2024

Reviewed but have a question. Should we also be supporting inline fragments? https://spec.graphql.org/October2021/#sec-Inline-Fragments

Fragments also support variables, if we want to support that too

Nice catch! We should be able to support inline fragments as well as variables. I'll add some tests to verify.

Update: Both work and are tested now.

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

func TestQuerySimpleWithFragmentsSucceeds(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: I'm not sure if you had changed them last time it was suggested but TestQuerySimple_WithFragments_Succeeds would read a little better and would be easier to go straight to the most descriptive part (WithFragment) of the test name.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM! I'm surprised how simple supporting fragments turned out to be.

@nasdf nasdf merged commit 79eb12c into sourcenetwork:develop Sep 25, 2024
41 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for GraphQL fragments
3 participants