-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: master
Are you sure you want to change the base?
Feature/gql exporter #433
Conversation
8e6ef04
to
dcde474
Compare
|
||
|
||
# ========= String converters ========= | ||
def to_camel_case(text: str) -> str: |
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.
Probably should be in utils
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.
There was some function for that, but it was not producing the expected output. I am not sure if any other exporter is using that, so I decided not to modify and write my own
return text[0].lower() + text[1:] | ||
|
||
|
||
def to_pascal_case(text: str) -> str: |
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.
Same, should be in utils
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.
There was some function for that, but it was not producing the expected output. I am not sure if any other exporter is using that, so I decided not to modify and write my own
return "".join(word[0].upper() + word[1:] for word in words) | ||
|
||
|
||
def to_screaming_snake_case(text: str) -> str: |
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.
Same
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.
There was some function for that, but it was not producing the expected output. I am not sure if any other exporter is using that, so I decided not to modify and write my own
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 |
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.
why does this need to be global and not just an argument / return value of the function?
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.
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
|
||
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 |
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.
So many globals. Isn't it possible to pass them through where needed?
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.
It is possible, but as I have many functions, it will imply passing them over multiple times.
5190be1
to
50cadb6
Compare
MoM:
|
): | ||
""" | ||
Export as GraphQL. | ||
Export a VSS specification to a GraphQL schema. | ||
""" | ||
tree, _ = get_trees( |
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.
what about the type tree aka structs?
50cadb6
to
a5728b5
Compare
4bec393
to
e864275
Compare
Signed-off-by: Daniel Alvarez-Coello <[email protected]>
e864275
to
fdaa94c
Compare
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
.