Homepage
Link to WPGraphQL on Github
Link to WPGraphQL on WordPress.org

register_graphql_interfaces_to_types

Given a type name and interface name, this applies the interface to the Type.

Parameters

  • $interface_names (array): An array of interface names to register the types to
  • $type_names (array): An array of type names to register the interfaces to

Source

File: access-functions.php

Examples

First an interface needs to be registered. This example adds an Interface Type called ExampleInterface to the GraphQL Schema with a test field called exampleField.

Now the ExampleInterface can be registered to a GraphQL Type. In this example, it is registered to the User object.

You can now write a query:

Which will return results similar to the following:

Here is how this looks inside GraphiQL:

Register an interface inside GraphiQL