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

Implement __type/__schema introspection disabling #2657

Merged

Conversation

TomasBarry
Copy link
Contributor

A question was asked in issue GH-2546 asking whether it was possible to
disable a single introspection entry point considering that #2327 had
implemented then functionality to disable introspection as a whole using
disable_introspection_entry_points. In the issue, an option was laid
out to implement the functionality for individual
disable_schema_introspection_entry_point and
disable_type_introspection_entry_point options. This commit implements
these methods.

These new methods are used in an identical manner to
disable_introspection_entry_points:

Disabling __type introspection

class MySchema < GraphQL::Schema
  disable_type_introspection_entry_point
end

With the above, attempting to execute a query with __type
introspection will return the following error message:

Field '__type' doesn't exist on type 'Query'

Disabling __schema introspection

class MySchema < GraphQL::Schema
  disable_schema_introspection_entry_point
end

With the above, attempting to execute a query with __schema
introspection will return the following error message:

Field '__schema' doesn't exist on type 'Query'

Note, having both disable_type_introspection_entry_point and
disable_schema_introspection_entry_point is identical to having just
disable_introspection_entry_points. Having
disable_introspection_entry_points and
disable_type_introspection_entry_point or
disable_schema_introspection_entry_point is no different to just
having disable_introspection_entry_points.

@TomasBarry TomasBarry force-pushed the feature/disable-introspection-options branch from 5b426d5 to 97243b2 Compare January 4, 2020 12:16
A question was asked in issue rmosolgoGH-2546 asking whether it was possible to
disable a single introspection entry point considering that rmosolgo#2327 had
implemented then functionality to disable introspection as a whole using
`disable_introspection_entry_points`. In the issue, an option was laid
out to implement the functionality for individual
`disable_schema_introspection_entry_point` and
`disable_type_introspection_entry_point` options. This commit implements
these methods.

These new methods are used in an identical manner to
`disable_introspection_entry_points`:

 # Disabling `__type` introspection

```ruby
class MySchema < GraphQL::Schema
  disable_type_introspection_entry_point
end
```

With the above, attempting to execute a query with `__type`
introspection will return the following error message:

```
Field '__type' doesn't exist on type 'Query'
```

 # Disabling `__schema` introspection
```ruby
class MySchema < GraphQL::Schema
  disable_schema_introspection_entry_point
end
```

With the above, attempting to execute a query with `__schema`
introspection will return the following error message:

```
Field '__schema' doesn't exist on type 'Query'
```

Note, having both `disable_type_introspection_entry_point` and
`disable_schema_introspection_entry_point` is identical to having just
`disable_introspection_entry_points`. Having
`disable_introspection_entry_points` and
`disable_type_introspection_entry_point` or
`disable_schema_introspection_entry_point` is no different to just
having `disable_introspection_entry_points`.
@TomasBarry TomasBarry force-pushed the feature/disable-introspection-options branch from 97243b2 to 53a7dbc Compare January 4, 2020 12:25
@rmosolgo
Copy link
Owner

Thanks for your work here! It looks great. I just pushed some changes to address the lint errors, then I'll merge it.

@rmosolgo rmosolgo added this to the 1.9.18 milestone Jan 13, 2020
@TomasBarry
Copy link
Contributor Author

For some reason I did not spot those errors. Thank you.

@rmosolgo rmosolgo merged commit 3e66fb2 into rmosolgo:master Jan 13, 2020
@TomasBarry TomasBarry deleted the feature/disable-introspection-options branch January 14, 2020 08:31
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 this pull request may close these issues.

2 participants