{"id":20253565,"url":"https://github.com/graphile/global-ids","last_synced_at":"2025-04-10T23:43:47.091Z","repository":{"id":34080078,"uuid":"168336926","full_name":"graphile/global-ids","owner":"graphile","description":"[EXPERIMENTAL] Allows you to use Relay global object identifiers in more places.","archived":false,"fork":false,"pushed_at":"2023-01-10T11:17:41.000Z","size":1480,"stargazers_count":9,"open_issues_count":8,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T23:43:41.382Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-30T12:09:07.000Z","updated_at":"2022-12-27T12:36:52.000Z","dependencies_parsed_at":"2023-01-15T04:30:07.652Z","dependency_job_id":null,"html_url":"https://github.com/graphile/global-ids","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fglobal-ids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fglobal-ids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fglobal-ids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphile%2Fglobal-ids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphile","download_url":"https://codeload.github.com/graphile/global-ids/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317726,"owners_count":21083527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T10:25:44.359Z","updated_at":"2025-04-10T23:43:47.067Z","avatar_url":"https://github.com/graphile.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @graphile/global-ids\n\nAllows you to use Relay global object identifiers in more places.\n\n## Purpose\n\nCurrently (v4.3.2) PostGraphile has support for Relay Global Object Identifiers:\n\n- On every table output type, primarily useful for caching\n- Fetching via the `{node:(nodeId: ...) {...}}` interface\n- Fetching via the table-specific `{myTable(nodeId: ...) {...}}` interface\n- Mutating via the `mutation {updateMyTable(input:{nodeId: ..., ...}){...}}` interface\n\nHowever, you still have to use the underlying primary keys in many places:\n\n- When referencing references to related tables: `mutation {updatePerson(input:{nodeId: ..., patch: {organizationId: 7}}){...}}`\n- When calling SQL functions\n- When dealing with custom types\n- More places?\n\nThis plugin aims to let you use global IDs in more places.\n\n## Status: Experimental\n\nAPIs in this plugin will currently be changing based on feedback from the\nsponsor, if you use this plugin in your stack expect your GraphQL API to\nchange shape over time until the dust settles.\n\nProgress:\n\n- [x] Write initial README\n- [x] Add nodeId support to relations in create mutations\n- [x] Add nodeId support to relations in update mutations\n- [x] Update README with instructions\n- [ ] Add nodeId support to relations in condition input\n- [ ] Add nodeId support to custom queries\n- [ ] Add nodeId support to custom mutations\n- [ ] Add nodeId support to computed columns (as secondary input)\n- [ ] Update README with instructions\n\n## Usage\n\nInstall:\n\n```bash\nyarn add @graphile/global-ids\n```\n\nLoad on command line:\n\n```bash\npostgraphile --append-plugins @graphile/global-ids\n```\n\nLoad in library usage:\n\n```js\napp.use(\n  postgraphile(DB, SCHEMA, {\n    //...\n    appendPlugins: [require(\"@graphile/global-ids\").default],\n  })\n);\n```\n\nNow you can choose to specify the NodeIDs through create/update mutations\ninstead of specifying the individual columns.\n\n## Why is this not part of PostGraphile core?\n\nGoing all-out on NodeIDs is a large undertaking right now. The hybrid\napproach this plugin takes moves some errors to run-time instead of\nbuild-time, and I don't want to compromise the default user experience.\n\nImagine you have a schema like in [`./schema.sql`](./schema.sql). You could\nissue a mutation such as:\n\n```graphql\nmutation CreateUser(\n  $user: UserInput = { organizationId: 27, name: \"Bobby Tables\" }\n) {\n  createUser(input: { user: $user }) {\n    user {\n      nodeId\n    }\n  }\n}\n```\n\nThe input object `UserInput` defines which fields are required:\n\n```graphql\ninput UserInput {\n  organizationId: Int!\n  uuid: UUID\n  name: String!\n}\n```\n\nIf you were to omit the `organizationId` then that would be a compile-time error.\n\nHowever, this plugin allows you to specify _either_ `organizationId` _or_\n`organizationNodeId`; and GraphQL currently does not have a way of\nrepresenting this data requirement. So we have to handle validation of the\nquery at run-time, when the mutation is executed, because the new `UserInput`\ntype will look like:\n\n```graphql\ninput UserInput {\n  organizationId: Int\n  organizationNodeId: ID\n  uuid: UUI\n  name: String!\n}\n```\n\nIt looks like both these `organization*` fields are optional, users have to\nrun the mutations to find out that they've missed a field that's implicitly\nrather than explicitly required.\n\nThis may change depending on progress on https://github.com/facebook/graphql/pull/395\n\nThe aim of this plugin is to introduce a hybrid approach for teams that\nwish to use NodeID everywhere, so we can discover everywhere it's necessary,\nand then in a later version of PostGraphile we may add a flag to alternate\nbetween the two methodologies.\n\n## Sponsorship\n\nThis plugin is sponsored by MRI Technologies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphile%2Fglobal-ids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphile%2Fglobal-ids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphile%2Fglobal-ids/lists"}