Sitecore GraphQL schema and query cache reset

As you know GraphQL requires schema to execute your queries. In Sitecore implementation the schema is regenerated every time you touch templates.

What we recently discovered, that if you have separate CD and CM, schema on CD node will not be refreshed after publish.

Luckily, this is quite easy to fix. You need to create an event handler and subscribe it to publish:end:remote event.


public class TemplateUpdateHandler : Sitecore.Services.GraphQL.Content.EventHandlers.TemplateUpdateHandler
{
public TemplateUpdateHandler(IGraphQLEndpointManager endpointManager) : base(endpointManager)
{
}

public void OnPublishEndRemote(object sender, EventArgs e)
{
base.Reset(null);
}
}

Sitecore GraphQL schema and query cache reset

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s