-
Notifications
You must be signed in to change notification settings - Fork 68
Catd graphql play #2100
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
Draft
grokspawn
wants to merge
6
commits into
operator-framework:main
Choose a base branch
from
grokspawn:catd-graphql-play
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Catd graphql play #2100
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
29beed8
initial vibe
grokspawn 2b2ddca
integration with existing http service endpoint
grokspawn f26b98e
allow POST method only for graphql handler
grokspawn c0f593d
functional, caching dynamic graphql server
grokspawn 58fbad3
claude-based storage/service interface division, missing preconditions
grokspawn 346cf0d
caehe on unpack; fix image verification policy
grokspawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # GraphQL Integration | ||
|
|
||
| This package provides dynamic GraphQL schema generation for operator catalog data, integrated into the catalogd storage server. | ||
|
|
||
| ## Usage | ||
|
|
||
| The GraphQL endpoint is now available as part of the catalogd storage server at: | ||
|
|
||
| ``` | ||
| {catalog}/api/v1/graphql | ||
| ``` | ||
|
|
||
| Where `{catalog}` is replaced by the actual catalog name at runtime. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ### Making a GraphQL Request | ||
|
|
||
| ```bash | ||
| curl -X POST http://localhost:8080/my-catalog/api/v1/graphql \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "query": "{ summary { totalSchemas schemas { name totalObjects totalFields } } }" | ||
| }' | ||
| ``` | ||
|
|
||
| ### Sample Queries | ||
|
|
||
| #### Get catalog summary: | ||
| ```graphql | ||
| { | ||
| summary { | ||
| totalSchemas | ||
| schemas { | ||
| name | ||
| totalObjects | ||
| totalFields | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Get bundles with pagination: | ||
| ```graphql | ||
| { | ||
| bundles(limit: 5, offset: 0) { | ||
| name | ||
| package | ||
| version | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Get packages: | ||
| ```graphql | ||
| { | ||
| packages(limit: 10) { | ||
| name | ||
| description | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Get bundle properties (union types): | ||
| ```graphql | ||
| { | ||
| bundles(limit: 5) { | ||
| name | ||
| properties { | ||
| type | ||
| value { | ||
| ... on PropertyValueFeaturesOperatorsOpenshiftIo { | ||
| disconnected | ||
| cnf | ||
| cni | ||
| csi | ||
| fips | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| - **Dynamic Schema Generation**: Automatically discovers schema structure from catalog metadata | ||
| - **Union Types**: Supports complex bundle properties with variable structures | ||
| - **Pagination**: Built-in limit/offset pagination for all queries | ||
| - **Field Name Sanitization**: Converts JSON field names to valid GraphQL identifiers | ||
| - **Catalog-Specific**: Each catalog gets its own dynamically generated schema | ||
|
|
||
| ## Integration | ||
|
|
||
| The GraphQL functionality is integrated into the `LocalDirV1` storage handler in `internal/catalogd/storage/localdir.go`: | ||
|
|
||
| - `handleV1GraphQL()`: Handles POST requests to the GraphQL endpoint | ||
| - `createCatalogFS()`: Creates filesystem interface for catalog data | ||
| - `buildCatalogGraphQLSchema()`: Builds dynamic GraphQL schema for specific catalogs | ||
|
|
||
| ## Technical Details | ||
|
|
||
| - Uses `declcfg.WalkMetasFS` to discover schema structure | ||
| - Generates GraphQL object types dynamically from discovered fields | ||
| - Creates union types for bundle properties with variable structures | ||
| - Supports all standard GraphQL features including introspection |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature gate
GraphQLCatalogQueriesis defined infeatures.gobut is never checked before enabling the GraphQL endpoint. The endpoint is unconditionally registered inhandlers.goline 67, regardless of the feature gate setting. This means the feature gate has no effect. The feature gate should be checked in the handler registration logic or when creating theCatalogHandlers.