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

Add docstring to generated code based on schema description #362

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

PaleNeutron
Copy link

@PaleNeutron PaleNeutron commented Mar 13, 2025

Implement #361

Now generated method and class will have docstring based on schema field and type description

output example

class Query:
    @classmethod
    def book_id(cls, para: bookIdParas) -> bookIdFields:
        """get book id from my database"""
        arguments: Dict[str, Dict[str, Any]] = {
            "para": {"type": "bookIdParas!", "value": para}
        }
        cleared_arguments = {
            key: value for key, value in arguments.items() if value["value"] is not None
        }
        return bookIdFields(field_name="bookId", arguments=cleared_arguments)

class bookIdFields(GraphQLField):
    """my book id"""

    book_id: "bookIdGraphQLField" = bookIdGraphQLField("book_id")

    def fields(self, *subfields: bookIdGraphQLField) -> "bookIdFields":
        """Subfields should come from the bookIdFields class"""
        self._subfields.extend(subfields)
        return self

    def alias(self, alias: str) -> "bookIdFields":
        self._alias = alias
        return self

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.

1 participant