mirumee / ariadne-graphql-modules

Ariadne package for implementing Ariadne GraphQL schemas using modular approach.

Home Page:https://ariadnegraphql.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Mutation type

rafalp opened this issue · comments

While mutations are already possible in future API via MutationType(ObjectType) sublclassing, we could also have extra MutationType base class that would represent single field on mutation:

class ErrorType(GraphQLObject):
  path: str
  code: str


class LoginMutation(MutationType):
    token: str | None
    errors: List[ErrorType] | None

    def __mutation__(_, info, username: str, password: str) -> LoginMutation:
        return LoginMutation(token="dsa87dsa98798sda")

Result:

type Mutation {
  login(username: String!, password: String!): LoginMutation!
}

type LoginMutation {
  token: String!
  errors: [ErrorType!]
}

type ErrorType {
  path: String!
  code: String!
}

We could use __graphql_name__ to rename LoginMutation to something else in schema, and have extra attr named __mutation_name__ to rename login on Mutation type to something else.