Skip to content

Conversation

@mraerino
Copy link
Contributor

@mraerino mraerino commented Aug 3, 2025

Fixes: #19622

This adds the ability to populate the query in the built-in GraphQL IDE (GraphiQL) using a parameter specified in the URL hash (aka fragment).

E.g.

https://<your netbox>/graphql/#query=%7Bdevice_list%28filters%3A%7Binterfaces%3A%7Bip_addresses%3A%7Bfamily%3AFAMILY_6%7D%7D%7D%29%7Binterfaces%7Bip_addresses%7Baddress%20family%7Blabel%7D%7D%7D%7D%7D

I considered adding a button to copy this kind of url to the UI, but the project setup for GraphiQL (the UI component) is pretty outdated and doesn't easily allow modifications.

@mraerino mraerino force-pushed the graphql-query-arg branch from 9ef2b07 to 1025f08 Compare August 3, 2025 12:02
@jnovinger jnovinger requested review from a team and jnovinger and removed request for a team August 3, 2025 21:26
@mraerino mraerino changed the title Allow loading graphql query from URL Allow loading graphql query from URL in GraphiQL Aug 3, 2025
@jnovinger jnovinger changed the title Allow loading graphql query from URL in GraphiQL Fixes #19622: Allow loading graphql query from URL in GraphiQL Aug 4, 2025
Copy link
Member

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

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

Totally understand leaving the "copy to URL" button as future work.

It seems like you can accomplish the task of creating the fragment from pretty much copy-pasting the existing query. I found it worked better to URLencode it before sharing, but it mostly worked without.

@jnovinger jnovinger merged commit 9df0bdc into netbox-community:main Aug 4, 2025
7 checks passed
@mraerino mraerino deleted the graphql-query-arg branch August 5, 2025 11:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow sharing GraphQL queries as links

2 participants