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

how to make shield work for conditionally lazyLoaded schema #1424

Open
ethdev279 opened this issue Aug 1, 2022 · 2 comments
Open

how to make shield work for conditionally lazyLoaded schema #1424

ethdev279 opened this issue Aug 1, 2022 · 2 comments

Comments

@ethdev279
Copy link

I'm trying to use graphql shield with envelop's useLazyLoadedSchema to use public and private schema's conditionally based on authorization passed to context like below

const permissions = shield({
Query : {
...
...
...
},
Mutation:{
...
...
...
}
});

const server = createServer({
  plugins: [
    useGraphQLMiddleware([permissions]),
    useLazyLoadedSchema(({ request }) => (request.headers.get('authorization') ? privateSchema : publicSchema))
  ]
})

So when we do this, shield may not be able to apply all rules to conditionally loaded schema so it throws the following expected error

It seems like you have applied rules to Query.getCompanies, Query.getReports fields but Shield cannot find them in your schema

is there any way we can suppress this error or make shield aware of the rules applied to non existing schema. instead of throwing error it should ignore it.

Originally posted by @ethdev279 in #1423

@open-collective-bot
Copy link

Hey @ethdev279 👋,

Thank you for opening an issue. We will get back to you as soon as we can. Have you seen our Open Collective page? Please consider contributing financially to our project. This will help us involve more contributors and get to issues like yours faster.

https://opencollective.com/graphql-shield

We offer priority support for all financial contributors. Don't forget to add priority label once you become one! 😄

@V-Voidula
Copy link

+1

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