authorfield in the "Article" content type. For this field we can have a producer that takes an entity and returns or resolves the creator field. Let's apply this to our custom schema which alreay defines an "Article" type.
.graphqlsfile add the schema defintion
authorfield on the Article type can be implemented in code. Like mentioned previously this is done inside the
src/Plugin/SchemaExtensionin your module. You can check the example module which already implements this as an example.
ResolverBuilderonce inside the
getResolverRegistryif you do not want to use schema extensions) in order to start registering resolvers. This is what will give you access to all the data producers by calling the
producemethod which takes as a parameter the data producer id.
producemethod with the data producer id is what you need to do every time you want to make a field available in the schema. We tell Drupal where and how to get the data and specify where this maps to.
property_pathdata producer that comes with the GraphQL module. It's one of the most common ones and you will find yourself using it often to resolve any kind of property on an entity. The module includes a lot more which we will see in the "Built in Data Producers" section.
field_article_creatorthe API would expose this field as
fieldArticleCreator. This means that the API consumer needs to have knowledge about how Drupal structures its data internally. In the 4.x module you can (and also need to) define your own custom schemas (and data producers) and therefore create your own structure so that someone that uses the API does not need to know how Drupal structures the data.