Skip to content

Type-checking resolvers #7

@SpaceK33z

Description

@SpaceK33z

Nexus has type-checking everywhere, but this plugin deviates from that in that it doesn't check if the resolvers actually exist. While building my first Nexus app I made the mistake for example to put the frontPage resolver in Mutation instead of Query and only found out much later. Would be really handy if this could give an error.

const permissions = shield({
  rules: {
    Query: {
      frontPage: not(isAuthenticated),
      asdf: isAuthenticated(), // <--- I want this to give a typecheck error if it does not exist
    },
    Mutation: {
      //
    },
  }
});

I was also thinking how cool it would be if instead of having one big "permissions" files that duplicates all the resolver names etc, you could add the permission like this;

schema.extendType({
  type: 'Query',
  definition(t) {
    t.field('frontPage', {
      permission: not(isAuthenticated), // <----
      resolve() {}
      // ...
    });
  }
});

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions