graphql-community / graphql-community/graphql-directive-auth

customAuth is not a function

Open
#33 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
135
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Hello. Forgive me for my bad english.

I'm trying to implement authentication and authorization in my graphql api. If I use :+1:
```
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 ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.