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

Restrict static introspection to only __schema and __type #1299

Merged
merged 2 commits into from Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEXT_CHANGELOG.md
Expand Up @@ -262,6 +262,11 @@ By [@garypen](https://github.com/garypen) in https://github.com/apollographql/ro

## 🐛 Fixes

### Restrict static introspection to only `__schema` and `__type` ([PR #1299](https://github.com/apollographql/router/pull/1299))
Queries with selected field names starting with `__` are recognized as introspection queries. This includes `__schema`, `__type` and `__typename`. However, `__typename` is introspection at query time which is different from `__schema` and `__type` because two of the later can be answered with queries with empty input variables. This change will restrict introspection to only `__schema` and `__type`.

By [@dingxiangfei2009](https://github.com/dingxiangfei2009) in https://github.com/apollographql/router/pull/1299

### Fix scaffold support ([PR #1293](https://github.com/apollographql/router/pull/1293))

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/1293
Expand Down
7 changes: 6 additions & 1 deletion apollo-router/src/spec/query.rs
Expand Up @@ -727,7 +727,12 @@ impl Operation {

fn is_introspection(&self) -> bool {
self.selection_set.iter().all(|sel| match sel {
Selection::Field { name, .. } => name.as_str().starts_with("__"),
Selection::Field { name, .. } => {
let name = name.as_str();
// `__typename` can only be resolved in runtime,
// so this query cannot be seen as an introspection query
name == "__schema" || name == "__type"
}
_ => false,
})
}
Expand Down