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

Feature/gql exporter #433

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdacoello
Copy link

This PR addresses the issue #431. It refactors entirely the GraphphQL exporter to offer a usable schema structure. For extended explanation, please see the updated documentation of the exporter docs/graphql.md.

src/vss_tools/exporters/jsonschema.py Outdated Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Show resolved Hide resolved
field_dict[additional_field[0]] = field(node, f" {str(additional_field[1])}: ")
def get_gql_unit_enums() -> Dict[str, graphene.Enum]:
"""Get GraphQL enums for VSS units and quantity kinds."""
global mapping_quantity_kinds_df
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does this need to be global and not just an argument / return value of the function?

Copy link
Author

Choose a reason for hiding this comment

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

For simplicity, to avoid passing that to many places. This variable is only modified once but accessed elsewhere

src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved

def get_graphql_schema(tree: VSSNode) -> graphene.Schema:
"""Create a GraphQL schema from the VSS tree."""
global vss_metadata_df, vss_branches_df, vss_leaves_df, gql_unit_enums, gql_allowed_enums, gql_instance_enums
Copy link
Collaborator

Choose a reason for hiding this comment

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

So many globals. Isn't it possible to pass them through where needed?

Copy link
Author

Choose a reason for hiding this comment

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

It is possible, but as I have many functions, it will imply passing them over multiple times.

@erikbosch
Copy link
Collaborator

MoM:

):
"""
Export as GraphQL.
Export a VSS specification to a GraphQL schema.
"""
tree, _ = get_trees(
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about the type tree aka structs?

src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved
src/vss_tools/exporters/graphql.py Outdated Show resolved Hide resolved
@jdacoello jdacoello force-pushed the feature/gql-exporter branch 5 times, most recently from fdaa94c to dea7c93 Compare November 30, 2024 05:23
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