Skip to content

Improve error message for resource.get that isn't unique #474

@benjie

Description

@benjie
   "message": "An error occurred (logged with hash: 'Attempted to call PgResource(dependency).get({id}) at child field (TODO: which one?) but that combination of attributes is not unique (uniques: [{\"isPrimary\":true,\"attributes\":[\"block_id\",\"dependency_id\"],\"extensions\":{\"tags\":{}}}]). Did you mean to call .find() instead?\n\nGraphQL HTTP Request:5:5\n4 |     success\n5 |     dependency {\n  |     ^\n6 |       id')",

Reported by @sgrove

Context: https://discord.com/channels/489127045289476126/498852330754801666/1139357431210704947

This error would be more helpful if it found the primary unique and then told you to do that instead, e.g.:

Attempted to call PgResource(dependency).get({id: ...}) at child field (TODO: which one?) but {PROBLEM}. Valid calls would look like {one of}: `.get({ block_id: ... })`, `.get({ organization_id: ..., number: ... })`, or if you want more than one record use `.find()` instead.

Where {PROBLEM} is something like:

- `id` is not a column of `{RESOURCE_NAME}`
- {these keys|this key} (`id`) does not uniquely identify a record

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    🌳 Triage

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions