ariadne-graphql-modules icon indicating copy to clipboard operation
ariadne-graphql-modules copied to clipboard

Support Mutation type

Open rafalp opened this issue 2 years ago • 1 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.

rafalp avatar Nov 21 '23 16:11 rafalp

This can be delayed after next API is released.

DamianCzajkowski avatar Aug 19 '24 08:08 DamianCzajkowski