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

Usage example #4

Open
RodolfoSilva opened this issue Aug 28, 2020 · 2 comments
Open

Usage example #4

RodolfoSilva opened this issue Aug 28, 2020 · 2 comments

Comments

@RodolfoSilva
Copy link

Hello @targos, @stropitek. Great job with this provider.
Do you have an example of how to use it?
Do you have an example with auth?

@stropitek
Copy link
Contributor

Hello @RodolfoSilva

To get started, install the package and execute the node ace invoke adonis-apollo in the terminal.

We don't have any public example. To manage authorization in graphql resolvers, you just have to pass the adonis request context in the graphql context

Here is a configuration example:

const config: ApolloConfig = {
  schemas: 'app/Schemas',
  resolvers: 'app/Resolvers',
  path: '/graphql',
  apolloServer: {
    introspection: true,
    context: ({ ctx }): ApolloContext => {
      return {
        ctx,
        user: ctx.auth.user,
      };
    },
  },
  executableSchema: {
    inheritResolversFromInterfaces: false,
  },
};

@RodolfoSilva
Copy link
Author

@stropitek thanks, it would be great if we have a way to use decoration or middleware to implement SDL guard.

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

2 participants