Namespacing/nesting queries and mutations in schema with Nexus and Shield
See original GitHub issueHey!
Thanks for the examples, they are super helpful 👏
I’m evaluating Nexus and Shield, and have taken the graphql-auth
project as a starter example. I’ve got the project up and running, and was trying to figure out how namespacing the schema would work - for example, nest all User
related queries and mutations under a User
namespace, so instead of
mutation {
login...
}
one would do
mutation {
user {
login...
}
}
Same goes for queries, where one would, for example, put the feed
, post
and filterPosts
queries under a post
namespace, i.e.
{
post {
feed...
filterPosts...
}
}
However, I can’t figure out how to
- Do that in Nexus - what would the return type of the new ‘root’ type (i.e. the
post
namespace for queries) be? - Is that even possible with Shield? It throws errors at me as soon as I try to make a deeper level of keys in the permissions, i.e. go from
export const permissions = shield({
Query: {
me: rules.isAuthenticatedUser,
filterPosts: rules.isAuthenticatedUser,
post: rules.isAuthenticatedUser,
},
Mutation: {...},
});
to
export const permissions = shield({
Query: {
me: rules.isAuthenticatedUser,
posts: {
filterPosts: rules.isAuthenticatedUser,
post: rules.isAuthenticatedUser,
}
},
Mutation: {...},
});
Not sure if this is the right place to post it @maticzav @schickling ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
3. Adding mutations to your API - GraphQL Nexus
Overview. In this chapter you're going to add some write capability to your API. You'll learn about: Writing GraphQL mutations; Exposing GraphQL objects...
Read more >Ultimate Authentication using GraphQL Nexus
This tutorial requires that you have a knowledge of GraphQL queries, mutation and context. This tutorial covers the following:.
Read more >Developing GraphQL APIs using Nexus - Formidable Labs
When developing a GraphQL API there are two popular approaches to create the GraphQL Schema: the schema-first approach and the code-first.
Read more >nexus-shield - npm
Nexus Shield is a nexus plugin that helps you create an authorization layer for your application. It is a replacement for the provided ......
Read more >Getting Started – GraphQL Yoga
The Query , Mutation and Subscription types are special since they act as an entry point to the graph. The GraphQL schema acts...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still not stale, go away stale bot! 😄
Not stale