# Graphql can't find entity by UUID

**URL:** <https://community.fibery.io/t/graphql-cant-find-entity-by-uuid/5783>\
**Category:** Get Help\
**Created:** [February 1, 2024, 5:47pm UTC](https://community.fibery.io/t/graphql-cant-find-entity-by-uuid/5783 "2024-02-01T17:47:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuri\_BC](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yuri_bc/32/8803_2.png) [@Yuri\_BC](https://community.fibery.io/u/Yuri_BC)\
**Post date:** [February 1, 2024, 5:47pm UTC](https://community.fibery.io/t/graphql-cant-find-entity-by-uuid/5783/1 "2024-02-01T17:47:25Z")

</div>

Having an entity UUID in a text field ‘Database Representation UUID’ of database ‘Utility/Database’, I try to get the database name of that entity. The purpose of the script is to maintain an up to date database name available as entity, to use in views and relationships. When the database name changes, the Utility/Database entity that represents it, will update that name using a script.

I came as far as trying to get the entity from the provide UUID, but for some reason the result is:

Console output:

```auto
Script execution error: Error: Entity with UUID fbdb1365-9267-4e87-a449-fc7e9a795e45 not found

```

The entity UUID above is actually present as entity of database ‘CCE Root/Page’, so the not found error is not because it does not exist.

Here is the script:

```auto
const fibery = context.getService('fibery');

async function main() {
    try {
        const entity = args.currentEntities[0];
        const entityWithUUID = await fibery.getEntityById('Utility/Database', entity.id, ['Database Representation Entity UUID']);
        const unknownEntityUUID = entityWithUUID['Database Representation Entity UUID'];

        // The space name
        const spaceName = 'CCE_Root';

        const query = `{getEntityById(id: "${unknownEntityUUID}") {id, name}}`;

        const result = await fibery.graphql(spaceName, query);

        if (result.data && result.data.getEntityById) {
            const unknownDatabaseName = result.data.getEntityById.name.split('/')[0];
            console.log(`Database name: ${unknownDatabaseName}`);
            return; // Exit the function if the entity is found
        } else {
            throw new Error(`Entity with UUID ${unknownEntityUUID} not found.`);
        }

    } catch (error) {
        console.error(`Script execution error: ${error}`);
    }
}

await main().catch((error) => {
    console.error(`Main function error: ${error}`);
});

```

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [February 1, 2024, 6:47pm UTC](https://community.fibery.io/t/graphql-cant-find-entity-by-uuid/5783/2 "2024-02-01T18:47:17Z")

</div>

> [@Yuri\_BC](#):
>
> Having an entity UUID in a text field ‘Database Representation UUID’ of database ‘Utility/Database’, I try to get the database name of that entity.

I don’t think that is possible, since entity UUID is only guaranteed to be unique _within a particular Database_ - they are not globally unique. That’s why API calls like `getEntityById` require both the “Type” and “Id” to identify an entity.

---

<div class="post-metadata">

**Author:** ![Oleg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/oleg/32/1887_2.png) [@Oleg](https://community.fibery.io/u/Oleg)\
**Post date:** [February 2, 2024, 8:52am UTC](https://community.fibery.io/t/graphql-cant-find-entity-by-uuid/5783/3 "2024-02-02T08:52:46Z")

</div>

> [@Yuri\_BC](#):
>
> ```auto
> const query = `{getEntityById(id: "${unknownEntityUUID}") {id, name}}`;
> 
> ```

There is no such method as `getEntityById`. Every database has it is own method to retrieve entities like `findBugs(id:{is :"<UUID>"}){id}`.

Please check [Fibery GraphQL API](https://api.fibery.io/graphql.html#filtering)

Thanks,  
Oleg
