Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Add abstract class to generation #116

Open

Description

@schickling

We should add the following to the generated main output:

export namespace UserResolvers {

  // ...

  export abstract class Class implements Type {
    id = (
      parent: User,
      args: {},
      ctx: Context,
      info: GraphQLResolveInfo
    ): string | Promise<string> => parent.id

    // more fields backed by `User` model ...
  }

}

This will enable the following usage which doesn't require ...PostResolvers.defaultResolvers:

import { UserResolvers } from '../generated/graphqlgen'
import { UserModel, PostModel } from '...'

export class User implements UserResolvers.Class {
  post: (parent: UserModel, args: {}, ctx: Context): PostModel => {
    return ...
  }
}

Note that in TypeScript this class-based approach currently requires you to explicitly provide types. This is a know TypeScript limitation and hopefully fixed soon. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions