Skip to content

Fix GraphQL query sent with hierarchical nodes #149

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

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

LucasG0
Copy link
Contributor

@LucasG0 LucasG0 commented Nov 22, 2024

No description provided.

@LucasG0 LucasG0 force-pushed the lgu-fix-node-hierarchical branch from 8e85fe6 to 88ad1c7 Compare November 22, 2024 10:58
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

@@             Coverage Diff             @@
##           develop     #149      +/-   ##
===========================================
+ Coverage    65.32%   65.36%   +0.03%     
===========================================
  Files           76       76              
  Lines         6942     6950       +8     
  Branches      1375     1377       +2     
===========================================
+ Hits          4535     4543       +8     
  Misses        2033     2033              
  Partials       374      374              
Flag Coverage Δ
python-3.10 44.37% <100.00%> (+0.06%) ⬆️
python-3.11 44.37% <100.00%> (+0.06%) ⬆️
python-3.12 44.37% <100.00%> (+0.06%) ⬆️
python-3.9 43.49% <100.00%> (+0.06%) ⬆️
python-filler-3.12 23.82% <0.00%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/node.py 68.75% <100.00%> (+0.24%) ⬆️

🚨 Try these New Features:

@LucasG0 LucasG0 force-pushed the lgu-fix-node-hierarchical branch from 88ad1c7 to 5ff89a9 Compare November 22, 2024 11:00
@LucasG0 LucasG0 changed the title Fix GraphQL query sent by sdk with hierarchical nodes Fix GraphQL query sent with hierarchical nodes Nov 22, 2024
@LucasG0 LucasG0 requested a review from a team November 22, 2024 11:11
@ogenstad
Copy link
Contributor

This looks good to me, it might be a bit weird that we start to use fragments without actually requesting fragments.

I.e. even if someone did this:

from infrahub_sdk import InfrahubClientSync

client = InfrahubClientSync()
nodes = client.all(kind="LocationSite", prefetch_relationships=True, populate_store=True, fragment=False)

We'd still use fragments which might seem confusing. Having said given how these hierarchial models work I think it's a good compromise and most users wouldn't care about the fact that these objects require fragments. Thoughts @gmazoyer?

It would be good to have a pipeline complete with this change in the main infrahub repo. Can you open a PR there that updates the submodule to this commit?

@gmazoyer
Copy link
Contributor

We'd still use fragments which might seem confusing. Having said given how these hierarchial models work I think it's a good compromise and most users wouldn't care about the fact that these objects require fragments. Thoughts @gmazoyer?

Actually the idea of using a fragment came up during our quick sync with. We thoughts that going down that path would simplify the code (instead of going through several if clauses) and probably would not hurt the user in the process. So I agreed with Lucas' choice, and thought it was a pretty good idea.

@@ -293,3 +293,28 @@ async def test_create_branch(self, client: InfrahubClient, db: InfrahubDatabase,
async def test_create_branch_async(self, client: InfrahubClient, db: InfrahubDatabase, init_db_base, base_dataset):
task_id = await client.branch.create(branch_name="new-branch-2", wait_until_completion=False)
assert isinstance(task_id, str)

# See issue #148.
Copy link
Contributor

Choose a reason for hiding this comment

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

I asked myself this once: should we just put the entire link to the issue as a comment to a test that solves it? I think it makes sense to have it/

Copy link
Contributor Author

@LucasG0 LucasG0 Nov 22, 2024

Choose a reason for hiding this comment

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

It depends on our preferencies, actually, I think I prefer full link too. It's a bit more verbose but it allows quicker access to corresponding issue, and it is even more relevant as we have now multiple repositories (at least sdk/server), and it should be easy to find/replace these links in case repositories names change.

@LucasG0
Copy link
Contributor Author

LucasG0 commented Nov 22, 2024

Main infrahub repo related PR: opsmill/infrahub#5023

@LucasG0 LucasG0 merged commit 04d80a2 into develop Nov 22, 2024
12 checks passed
@LucasG0 LucasG0 deleted the lgu-fix-node-hierarchical branch November 22, 2024 16:01
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