Skip to content

Hide schema sections? #681

Answered by rafalp
otryshko asked this question in Q&A
Sep 27, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

There are two approaches to this:

Schema inheritance

This approach relies on GraphQL extend syntax which allows you to define additional fields for type after it was declared:

type MyType {
  somefield: String
}

extend type MyType {
  someSecretField: String
}

The trick is to run make_executable_schema twice, and pass only MyType with its resolvers to first run, and MyType together with extend (and extra types as well as resolvers) to next run. Then you setup two GraphQL urls and let client decide if they'll query /graphql/ or /graphql/private/. You can also put auth check in front of the URL to refuse queries without authorization to the private API.

Here's example repo that implements s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@otryshko
Comment options

Answer selected by otryshko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants