👀 See Sanity in action: Watch product demo now →

Error - Invalid Key: The GraphQL Query at the Field at Route:X

2 replies
Last updated: Jun 23, 2021
I’m using a graphql query to get pages, which include
slug
type objects - but I am seeing this warning:

Invalid key: The GraphQL query at the field at `Route:86842a74-fd68-4fcc-a9ad-2071a1b53714.slug` has a selection set, but no key could be generated for the data at this field.
You have to request `id` or `_id` fields for all selection sets or create a custom `keys` config for `Slug`.
Entities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `Slug` that always returns null.
Can anyone help me with how to fix that? The
slug
model doesn’t seem to have an
_id
field
May 20, 2021, 2:18 AM
can you post the query?
Jun 19, 2021, 9:27 AM
Actually
user X
I think it’s fine, the
_key
is null on all slugs but they have a
current
value which is basically unique, so I think I can just use that as the custom key for gql caching
Jun 23, 2021, 7:20 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in