question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validation errors can be used to get schema details

See original GitHub issue

Similar to introspection, another way to probe a server for details about its schema is to submit invalid GraphQL documents so that the default validation rules provide data back. A variety of rules use didYouMean.js to give the developer suggestions about possible changes to get a valid document. This is ideal when developing against an API, but also is a channel for leaking information (like prototype features) with validation rules like FieldsOnCorrectType.

In production, some companies with internal schemas elect to disable introspection, where internally they can acquire their schema via other channels. Seemingly security through obscurity.

The validation rules still need to run, but it would be ideal if we could toggle the ability to provide suggestions as part of the error message. The ValidationContext does provide onError handler, but it seems a bit reactive and wasteful to then remove the computed suggestionList. This also ties into some ideas outlined in https://github.com/graphql/graphql-js/pull/2074.

For example, Apollo Server provides a convenient constructor option introspection flag to determine if an introspection query should be allowed. It would be an improved developer experience if this flag could inform the underlying GraphQL.js validation rules to restrict its error messaging without any additional configuration required.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:15
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
leebyroncommented, Apr 8, 2021

I don’t really have a crisp proposal - just trying to clarify the need.

That seems like a reasonable way to implement introspection blocking, though I would worry about a theoretical misuse that creates a security risk where a query skips validation in some way and is still executed and exposes introspection. It might be nice if this was implemented within GraphQL.js that in addition to the clear error, it also simply wasn’t possible to execute introspection queries on a schema with introspection disabled.

My concern with granular controls is that a user would disable introspection but not consider disabling didYouMean and inadvertently open this internal information leak. I would expect that a schema with introspection disabled would also disable didYouMean.

I can’t think of a reason why you would want to disable introspection but enable didYouKnow or vice-versa.

3reactions
leebyroncommented, Apr 6, 2021

Based on the OP intent, should there be a single flag to disable introspection that also disables didYouMean?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Schema Validation Errors
In this guide we will go over schema validation errors in more detail; specifically, ... With rich results, you can use these tools...
Read more >
How to Fix Schema Validation Errors - WebFX
Wondering how to fix schema validation errors? Check out this guide on how to detect and fix these errors for your website!
Read more >
How to Fix Schema Validation Errors - DashClicks
Website owners must know everything about schema validation errors and how to fix them. The article will also discuss the most common Schema...
Read more >
Understanding schema errors | HESA
Schema errors prevent the validation being run in full because the file cannot be read. This means that errors cannot be traced to...
Read more >
Handling Validation Errors - python-jsonschema
When an invalid instance is encountered, a ValidationError will be raised or returned, depending on which method or function is used. exception jsonschema....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found