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

schema-codegen should generate mutation methods #3249

Open
1 of 3 tasks
c0dezer019 opened this issue Nov 22, 2023 · 1 comment
Open
1 of 3 tasks

schema-codegen should generate mutation methods #3249

c0dezer019 opened this issue Nov 22, 2023 · 1 comment

Comments

@c0dezer019
Copy link

c0dezer019 commented Nov 22, 2023

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

What it does

schema-codegen currently generates the following from the schema:

import strawberry

@strawberry.type
class Member:
    username: str

@strawberry.type
class Query:
    member: Member | None

@strawberry.type
class Mutation:
    create_user: Member

schema = strawberry.Schema(query=Query, mutation=Mutation)

Here's the schema for reference:

schema {
    query: Query
    mutation: Mutation
}

type Member {
    username: String!
}

type Query {
    member: Member
}

type Mutation {
    createMember(name: String!): Member!
}

What it should do

Instead, it should generate the following for our mutations:

@strawberry.type
class Mutation:
    @strawberry.mutation
    def create_member(self, name: str) -> Member:
        return Member(name=name)

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@c0dezer019 c0dezer019 changed the title [schema-codegen] schema-codegen should generate mutation methods schema-codegen should generate mutation methods Nov 22, 2023
@patrick91
Copy link
Member

One note on this, we'll probably generate an empty method instead of what you wrote, as it won't be easy to generate something that's actually valid (and useful)

@strawberry.type
class Mutation:
    @strawberry.mutation
    def create_member(self, name: str) -> Member:
        ...

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

No branches or pull requests

2 participants