Removing types from the schema

There are two ways to remove types from the schema:

  1. In all schemas, by disabling the corresponding "schema type" module
  2. In specific schemas, by disabling access to the corresponding connection fields

1. Disabling "schema type" modules permalink

Similar to functionality, GraphQL schema types are provided via modules. When browsing all modules in the Modules page, we can filter the schema type ones by clicking on the "Schema Type" category:

Schema type modules
Schema type modules

To remove a type from the schema, we then disable the corresponding module, as explained in guide Browsing, enabling and disabling modules.

This will remove the type in all schemas.

For instance, if we don't need comments on the site, we can remove the Comment type by disabling module "Schema Comments".

2. Disabling access to connection fields permalink

We can also remove a schema type by disabling access to all fields which return that type. To do this, we must add the access control rule "Disable access" for the field in some access control list (ACL), make it private, and assign the ACL to the corresponding schema configuration.

This will remove the type only for the selected schemas.

For instance, if we don't need comments on the site, we can remove the Comment type by disabling access to all fields from the Commentable interface (which is implemented by all types having comments, such as Post, Page, CustomPost, etc):

Removing a type by disabling access to fields
Removing a type by disabling access to fields

Share on 🐦 Twitter | πŸ‘ŽπŸΎ Facebook