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

[Proposal] Extend TypeName to other types #451

Open
Sytten opened this issue Jun 12, 2020 · 0 comments
Open

[Proposal] Extend TypeName to other types #451

Sytten opened this issue Jun 12, 2020 · 0 comments
Labels
type/feat Add a new capability or enhance an existing one

Comments

@Sytten
Copy link
Collaborator

Sytten commented Jun 12, 2020

I would like to propose an upgrade to the typing system.
Currently when creating plugins you have to limit the generics to extends string if you want to be able to access values using RootValue for example. It would be great to be able to use NexusObjectTypeDef instead. Here is an example from the plugin I am currently working on:

const myRule = ruleType({
  type: Test, // Not possible since NexusObjectTypeDef<'Test'> is no assignable to 'Test'
  resolve: (_root, _args, _ctx, _info) => {
    return true;
  },
});

export const Test = objectType({
  name: 'Test',
  definition(t) {
    t.id('id');
    t.string('prop');
    t.field('test', {
      type: EnumTest,
      shield: myRule,
      resolve(_root) {
        return 'test';
      },
    });
  },
});
@Weakky Weakky added the type/feat Add a new capability or enhance an existing one label Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feat Add a new capability or enhance an existing one
Projects
None yet
Development

No branches or pull requests

2 participants