Skip to content

customAuth is not a function #33

@zerr0s

Description

@zerr0s

Hello. Forgive me for my bad english.

I'm trying to implement authentication and authorization in my graphql api. If I use 👍

const customAuth = AuthDirective({
  authenticateFunc: () => {
    throw new AuthenticationError('Invalid token!');
  }
});

const server = new ApolloServer({
  typeDefs,
  resolvers,
  schemaDirectives: {
    ...customAuth
  }
});

It's working. But I'm trying to use a custom function:

const server = new ApolloServer({
  typeDefs,
  resolvers,
  schemaDirectives: {
    auth: customAuth().isAuthenticated
  }
});

The results is:

TypeError: customAuth is not a function

If I replace by

auth: customAuth.isAuthenticated

The directive is not working at all, but no error in console.

Any idea please ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions