Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Allow introspection by default in production mode #308

Merged
merged 4 commits into from Jan 31, 2019

Conversation

pmclain
Copy link
Contributor

@pmclain pmclain commented Dec 31, 2018

Description (*)

Adds env.php parameter for disabling introspection:

...
    'graphql' => [
        'disable_introspection' => true,
    ],
...

Fixed Issues (if relevant)

  1. GraphQL tools cannot perform "standard introspection query" in production mode #232: GraphQL tools cannot perform "standard introspection query" in production mode

Manual testing scenarios (*)

Validate disabled

  1. Enable production mode
  2. Add the following to env.php:
...
    'graphql' => [
        'disable_introspection' => true,
    ],
...
  1. Query:
{
  __schema {
    types {
      name
      interfaces {
        name
        description
      }
    }
  }
}
  1. Expect error message GraphQL introspection is not allowed, but the query contained __schema or __type

Validate enabled

  1. Enable production mode
  2. Add the following to env.php, or ensure path graphql/disable_introspection is not set:
...
    'graphql' => [
        'disable_introspection' => false,
    ],
...
  1. Query:
{
  __schema {
    types {
      name
      interfaces {
        name
        description
      }
    }
  }
}
  1. Expect valid response

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Adds env.php parameter for disabling introspection:
```php
...
    'graphql' => [
        'disable_introspection' => true,
    ],
...
```

Fixes magento#232
naydav and others added 3 commits January 23, 2019 16:54
The constructor value passed to `GraphQL\Validator\Rules\DisableIntrospection`
must be `int 0` to enable intropection.
@@ -53,7 +61,7 @@ public function __construct(
public function execute(): void
{
DocumentValidator::addRule(new QueryComplexity($this->queryComplexity));
DocumentValidator::addRule(new DisableIntrospection());
DocumentValidator::addRule(new DisableIntrospection((int) $this->introspectionConfig->isIntrospectionDisabled()));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naydav I updated this line casting the bool to int after this change way pushed yesterday b6fe3ff Passing anything other than int 0 here disables introspection https://github.com/webonyx/graphql-php/blob/v0.12.6/src/Validator/Rules/DisableIntrospection.php#L31

@magento-engcom-team magento-engcom-team merged commit 5b53536 into magento:2.3-develop Jan 31, 2019
@ghost
Copy link

ghost commented Jan 31, 2019

Hi @pmclain, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants