Content-Length: 329466 | pFad | http://github.com/nautobot/nautobot/pull/6752/commits/71f79dffc45b251558896546c8c0a25252e07eac

BF GraphQL as a Git Data source provider. by djhoward12 · Pull Request #6752 · nautobot/nautobot · 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

GraphQL as a Git Data source provider. #6752

Merged
merged 23 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8428c21
initial commit for graphql as a git data source
Jan 9, 2025
c2442f5
Merge branch 'develop' of https://github.com/djhoward12/nautobot into…
Jan 9, 2025
0a26195
Adding conditional for isdir and stripped extension from filename whe…
Jan 9, 2025
89f42b9
Merge branch 'nautobot:develop' into develop
djhoward12 Jan 9, 2025
934cbce
Update nautobot/docs/user-guide/feature-guides/git-data-source.md
djhoward12 Jan 9, 2025
22f63dd
Update nautobot/docs/user-guide/feature-guides/git-data-source.md
djhoward12 Jan 9, 2025
00ca2e2
Update nautobot/docs/user-guide/feature-guides/git-data-source.md
djhoward12 Jan 9, 2025
e24c920
Update nautobot/extras/datasources/git.py
djhoward12 Jan 9, 2025
bd37894
Adjusting tests for missing .gql extension and updates per PR comments.
Jan 10, 2025
317b021
Merge branch 'nautobot:develop' into develop
djhoward12 Jan 10, 2025
dfedd27
Merge branch 'develop' into develop
HanlinMiao Jan 15, 2025
e1574e8
Addressing PR comments, clear error msg, spelling error, add flag, up…
Jan 16, 2025
04c4e70
Merge branch 'develop' into develop
djhoward12 Jan 16, 2025
71f79df
Addressing PR comments. Don't delete query if exists and update has s…
Jan 16, 2025
806dc77
Merge branch 'nautobot:develop' into develop
djhoward12 Jan 16, 2025
290a92c
Update nautobot/extras/datasources/git.py
djhoward12 Jan 16, 2025
0242a2f
moving query=query content inside if. removing extra appends.
Jan 16, 2025
c8f4ae0
Merge branch 'develop' into develop
djhoward12 Jan 17, 2025
a0e241b
Merge branch 'develop' into develop
glennmatthews Jan 21, 2025
b917d0e
updating documentation to be in line with updates in #6801.
Jan 22, 2025
0693ee8
Merge branch 'nautobot:develop' into develop
djhoward12 Jan 22, 2025
30b476b
Merge branch 'develop' into develop
glennmatthews Jan 22, 2025
9c2df03
Update changes/4702.added
glennmatthews Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing PR comments. Don't delete query if exists and update has s…
…yntax error, added try, except.
  • Loading branch information
“DJ committed Jan 16, 2025
commit 71f79dffc45b251558896546c8c0a25252e07eac
63 changes: 40 additions & 23 deletions nautobot/extras/datasources/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,29 +977,41 @@ def update_git_graphql_queries(repository_record, job_result):
owner_object_id=repository_record.pk,
defaults={"query": query_content},
)
modified = False

# Check and update the query content
if graphql_query.query != query_content:
graphql_query.query = query_content
modified = True
modified = graphql_query.query != query_content

# Only attempt to update if the content has changed
if modified:
graphql_query.save()

graphql_queries.append(query_name)

# Log success
if created:
msg = f"Successfully created GraphQL query: {query_name}"
elif modified:
msg = f"Successfully refreshed GraphQL query: {query_name}"
graphql_query.query = query_content
djhoward12 marked this conversation as resolved.
Show resolved Hide resolved
try:
# Validate and save the query
graphql_query.full_clean()
graphql_query.save()
djhoward12 marked this conversation as resolved.
Show resolved Hide resolved
msg = (
f"Successfully created GraphQL query: {query_name}"
if created
else f"Successfully updated GraphQL query: {query_name}"
)
graphql_queries.append(query_name)
djhoward12 marked this conversation as resolved.
Show resolved Hide resolved
logger.info(msg)
job_result.log(
msg, obj=graphql_query, level_choice=LogLevelChoices.LOG_INFO, grouping="graphql queries"
)
except Exception as exc:
# Log validation error and retain the existing query
error_msg = (
f"Invalid GraphQL syntax for query '{query_name}'. "
f"Retaining the existing query. Error: {exc}"
)
logger.error(error_msg)
job_result.log(error_msg, level_choice=LogLevelChoices.LOG_ERROR, grouping="graphql queries")
graphql_queries.append(query_name) # Preserve the existing query despite the error
else:
msg = f"No changes to GraphQL query: {query_name}"
logger.info(msg)
job_result.log(
msg, obj=graphql_query, level_choice=LogLevelChoices.LOG_INFO, grouping="graphql queries"
)
graphql_queries.append(query_name) # Add to preserved list
logger.info(msg)
job_result.log(
msg, obj=graphql_query, level_choice=LogLevelChoices.LOG_INFO, grouping="graphql queries"
)

except Exception as exc:
# Check if a query with the same name already exists
Expand Down Expand Up @@ -1031,10 +1043,15 @@ def delete_git_graphql_queries(repository_record, job_result, preserve=None):
owner_object_id=repository_record.pk,
):
if graphql_query.name not in preserve:
graphql_query.delete()
msg = f"Deleted GraphQL query: {graphql_query.name}"
logger.warning(msg)
job_result.log(msg, level_choice=LogLevelChoices.LOG_WARNING, grouping="graphql queries")
try:
graphql_query.delete()
msg = f"Deleted GraphQL query: {graphql_query.name}"
logger.warning(msg)
job_result.log(msg, level_choice=LogLevelChoices.LOG_WARNING, grouping="graphql queries")
except Exception as exc:
error_msg = f"Unable to delete '{graphql_query.name}': {exc}"
logger.error(error_msg)
job_result.log(error_msg, level_choice=LogLevelChoices.LOG_ERROR, grouping="graphql queries")


# Register built-in callbacks for data types potentially provided by a GitRepository
Expand Down
Loading








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: http://github.com/nautobot/nautobot/pull/6752/commits/71f79dffc45b251558896546c8c0a25252e07eac

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy