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

Incomplete support for introspection queries #1230

Closed
Geal opened this issue Jun 14, 2022 · 1 comment · Fixed by #1240
Closed

Incomplete support for introspection queries #1230

Geal opened this issue Jun 14, 2022 · 1 comment · Fixed by #1240
Assignees

Comments

@Geal
Copy link
Contributor

Geal commented Jun 14, 2022

In the selections parsing, we recognize introspection fields using the __ prefix:

let field_type = if field_name.as_str() == "__typename" {
FieldType::String
} else if field_name.starts_with("__") {
FieldType::Introspection(field_name.clone())
} else {
current_type
.inner_type_name()
.and_then(|name| {
//looking into object types
schema
.object_types
.get(name)
.and_then(|ty| ty.field(&field_name))
// otherwise, it might be an interface
.or_else(|| {
schema
.interfaces
.get(name)
.and_then(|ty| ty.field(&field_name))
})
})
.ok_or_else(|| SpecError::InvalidType(current_type.clone()))?
.clone()
};

But it is not enough for introspection queries. With the following query:

query {
  __schema {
    queryType {
      name
    }
  }
}

We would recognize __schema, but then queryType is unknown because we do not know the fields of the __Schema type.

To fix that, the schema object should carry by default the introspection object types

@Geal Geal mentioned this issue Jun 14, 2022
3 tasks
@bnjjj
Copy link
Contributor

bnjjj commented Jun 14, 2022

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

Successfully merging a pull request may close this issue.

2 participants