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

customAuth is not a function #33

Open
zerr0s opened this issue Jul 12, 2020 · 0 comments
Open

customAuth is not a function #33

zerr0s opened this issue Jul 12, 2020 · 0 comments

Comments

@zerr0s
Copy link

zerr0s commented Jul 12, 2020

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant