Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: turning Node ID into underlying database ID #458

Open
benjie opened this issue Aug 9, 2023 · 1 comment
Open

Documentation: turning Node ID into underlying database ID #458

benjie opened this issue Aug 9, 2023 · 1 comment

Comments

@benjie
Copy link
Member

benjie commented Aug 9, 2023

See https://discord.com/channels/489127045289476126/498852330754801666/1138749365096304660

Yeah, I guess I need to add something like https://postgraphile.org/postgraphile/next/make-extend-schema-plugin#mutation-example-with-node-id to https://postgraphile.org/postgraphile/next/node-id to help people find it.

This also depends on graphile/crystal#2013 really.

@benjie benjie added this to the V5 RC milestone Aug 9, 2023
@benjie
Copy link
Member Author

benjie commented Aug 9, 2023

Specifically, it's

const handler = build.getNodeIdHandler("Chain");

and

const spec = specFromNodeId(handler, $nodeId);
const $id = spec.id;

Or something like that, depending on the shape of your table. E.g. if you have a composite primary key (organization_id, issue_id) then it might be:

const {
  organization_id: $organizationId,
  issue_id: $issueId,
} = specFromNodeId(handler, $nodeId);

Also note that if the NodeID is incompatible with this type then these values will be null (I think?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📝 Docs Improvements
Development

No branches or pull requests

1 participant