-
Notifications
You must be signed in to change notification settings - Fork 1
feat: make all queries/mutations available in the SDK with typed methods (HEXA-1305) #275
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
Closed
yolanfery
wants to merge
5
commits into
main
from
HEXA-1305-make-all-queries-available-in-the-sdk-and-update-wiki-with-example
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # AI tools settings | ||
| /.claude/settings.local.json | ||
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 |
|---|---|---|
|
|
@@ -148,6 +148,42 @@ You can run the tests using pytest: | |
| pytest | ||
| ``` | ||
|
|
||
| ### Codegen from the GraphQL schema | ||
|
|
||
| We use code generation to create Python client code from our GraphQL schema. This involves two tools: | ||
|
|
||
| 1. [**ariadne-codegen**](https://github.com/mirumee/ariadne-codegen): Generates typed Python GraphQL client code from GraphQL files | ||
| 2. [**gqlg**](https://github.com/timqian/gql-generator): Automatically generates comprehensive GraphQL queries for all queries and mutations defined in the schema | ||
|
|
||
| The code generation process: | ||
|
|
||
| 1. The GraphQL schema is manually taken from the [Openhexa Monorepo](https://github.com/BLSQ/openhexa-app/blob/main/frontend/schema.generated.graphql) and saved in [`openhexa/cli/graphql/schema.generated.graphql`](https://github.com/BLSQ/openhexa-sdk-python/blob/main/openhexa/cli/graphql/schema.generated.graphql) | ||
| 2. `gqlg` generates all possible queries/mutations from the schema with a depth limit of 3 | ||
| 3. `ariadne-codegen` uses both the schema and queries to generate typed Python client code | ||
|
|
||
| To run code generation manually: | ||
|
|
||
| ```shell | ||
| npm install gql-generator -g | ||
| pip install ariadne-codegen | ||
| gqlg --schemaFilePath ./openhexa/cli/graphql/schema.generated.graphql --destDirPath ./openhexa/cli/graphql/queries/gqlg --depthLimit 3 | ||
| ariadne-codegen | ||
| ``` | ||
|
|
||
| Both tools run automatically via pre-commit hooks and CI/CD when GraphQL files are modified. | ||
|
|
||
| You can add new queries or mutations in the [`openhexa/cli/graphql/queries/queries.graphql`](https://github.com/BLSQ/openhexa-sdk-python/blob/main/openhexa/cli/graphql/queries.graphql) directory, and they will be picked up by the code generation process. | ||
|
|
||
| Example of usage of the result : | ||
| ```python | ||
| from openhexa.cli.api import OpenHexaClient, CreateWebappInput, AddToFavoritesInput | ||
|
|
||
| client = OpenHexaClient() | ||
| new_webapp_id = client.create_webapp(input=CreateWebappInput(description="", icon="", name="",workspaceSlug="", url="")).create_webapp.webapp.id | ||
| client.add_to_favorites(input=AddToFavoritesInput(webappId=new_webapp_id)) | ||
|
Comment on lines
+179
to
+183
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example of usage |
||
|
|
||
| ``` | ||
|
|
||
| ## Release | ||
|
|
||
| This project uses [release-please](https://github.com/googleapis/release-please) to manage releases using conventional commits. | ||
|
|
||
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
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.
let's introduce our new co-worker☺️
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.
welcome claude