# Is there a wildcard for declaring all entities custom keyFields in the typePolicies?

**URL:** <https://community.apollographql.com/t/is-there-a-wildcard-for-declaring-all-entities-custom-keyfields-in-the-typepolicies/5366>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [January 3, 2023, 4:15pm UTC](https://community.apollographql.com/t/is-there-a-wildcard-for-declaring-all-entities-custom-keyfields-in-the-typepolicies/5366 "2023-01-03T16:15:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ma-ft](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/ma-ft/32/3646_2.png) [@Ma-ft](https://community.apollographql.com/u/Ma-ft)\
**Post date:** [January 3, 2023, 4:15pm UTC](https://community.apollographql.com/t/is-there-a-wildcard-for-declaring-all-entities-custom-keyfields-in-the-typepolicies/5366/1 "2023-01-03T16:15:01Z")

</div>

When creating a new InMemoryCache is there a way to say

```auto
 "*": {
      keyFields: ["uuid"],
    },

```

instead of

```auto
 Entity1: {
      keyFields: ["uuid"],
    },
 Entity2: {
      keyFields: ["uuid"],
    },
 Entity3: {
      keyFields: ["uuid"],
    },

```

---

<div class="post-metadata">

**Author:** ![jerelmiller](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jerelmiller/32/3314_2.png) [@jerelmiller](https://community.apollographql.com/u/jerelmiller)\
**Post date:** [January 4, 2023, 6:57pm UTC](https://community.apollographql.com/t/is-there-a-wildcard-for-declaring-all-entities-custom-keyfields-in-the-typepolicies/5366/2 "2023-01-04T18:57:15Z")

</div>

Hey @Ma-ft 👋!

Take a look at the [`dataIdFromObject` API](https://www.apollographql.com/docs/react/caching/cache-configuration/#customizing-identifier-generation-globally). This might be what you’re looking for as it allows you to define global fallback cache ID.

---

<div class="post-metadata">

**Author:** ![Ma-ft](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/ma-ft/32/3646_2.png) [@Ma-ft](https://community.apollographql.com/u/Ma-ft)\
**Post date:** [January 4, 2023, 7:15pm UTC](https://community.apollographql.com/t/is-there-a-wildcard-for-declaring-all-entities-custom-keyfields-in-the-typepolicies/5366/3 "2023-01-04T19:15:38Z")

</div>

Thanks i ended up going with below

```typescript
import { defaultDataIdFromObject } from '@apollo/client';

const cache = new InMemoryCache({
  dataIdFromObject: (r) => {
    if (r.__typename) {
      return (r.uuid as unknown) as string;
    }
    return defaultDataIdFromObject(r);
  },
});

```

now i can just focus on explicit typePolicies for outlier Entities 👍
