{"id":28714357,"url":"https://github.com/graphql-compose/graphql-compose-relay","last_synced_at":"2025-06-15T01:07:01.711Z","repository":{"id":9557405,"uuid":"62532792","full_name":"graphql-compose/graphql-compose-relay","owner":"graphql-compose","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-06T01:43:20.000Z","size":4159,"stargazers_count":29,"open_issues_count":23,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-01T08:13:54.947Z","etag":null,"topics":["graphql","graphql-compose","graphql-compose-plugin","relay","schema-builder"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/graphql-compose.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-07-04T05:03:42.000Z","updated_at":"2021-06-25T17:59:18.000Z","dependencies_parsed_at":"2023-01-13T16:24:00.493Z","dependency_job_id":null,"html_url":"https://github.com/graphql-compose/graphql-compose-relay","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-compose%2Fgraphql-compose-relay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-compose%2Fgraphql-compose-relay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-compose%2Fgraphql-compose-relay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-compose%2Fgraphql-compose-relay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-compose","download_url":"https://codeload.github.com/graphql-compose/graphql-compose-relay/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-compose%2Fgraphql-compose-relay/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258511086,"owners_count":22712966,"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":["graphql","graphql-compose","graphql-compose-plugin","relay","schema-builder"],"created_at":"2025-06-15T01:07:00.950Z","updated_at":"2025-06-15T01:07:01.683Z","avatar_url":"https://github.com/graphql-compose.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-compose-relay\n\n[![travis build](https://img.shields.io/travis/graphql-compose/graphql-compose-relay.svg)](https://travis-ci.org/graphql-compose/graphql-compose-relay)\n[![codecov coverage](https://img.shields.io/codecov/c/github/graphql-compose/graphql-compose-relay.svg)](https://codecov.io/github/graphql-compose/graphql-compose-relay)\n[![](https://img.shields.io/npm/v/graphql-compose-relay.svg)](https://www.npmjs.com/package/graphql-compose-relay)\n[![npm](https://img.shields.io/npm/dt/graphql-compose-relay.svg)](http://www.npmtrends.com/graphql-compose-relay)\n[![Join the chat at https://gitter.im/graphql-compose/Lobby](https://badges.gitter.im/graphql-compose/graphql-compose.svg)](https://gitter.im/graphql-compose/Lobby)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Greenkeeper badge](https://badges.greenkeeper.io/graphql-compose/graphql-compose-relay.svg)](https://greenkeeper.io/)\n\n\nThis is a plugin for [graphql-compose](https://github.com/graphql-compose/graphql-compose), which wraps GraphQL types with Relay specific things, like `Node` type and interface, `globalId`, `clientMutationId`.\n\nLive demo: [https://graphql-compose.herokuapp.com/](https://graphql-compose.herokuapp.com/)\n\n[CHANGELOG](https://github.com/graphql-compose/graphql-compose-relay/blob/master/CHANGELOG.md)\n\nInstallation\n============\n```\nnpm install graphql graphql-compose graphql-compose-relay --save\n```\nModules `graphql` and `graphql-compose` are in `peerDependencies`, so should be installed explicitly in your app. They have global objects and should not have ability to be installed as submodule.\n\nExample\n=======\n`ObjectTypeComposer` is a [graphql-compose](https://github.com/graphql-compose/graphql-compose) utility, that wraps GraphQL types and provide bunch of useful methods for type manipulation.\n```js\nimport composeWithRelay from 'graphql-compose-relay';\nimport { ObjectTypeComposer } from 'graphql-compose';\nimport { RootQueryType, UserType } from './my-graphq-object-types';\n\nconst queryTC = new ObjectTypeComposer(RootQueryType);\nconst userTC = new ObjectTypeComposer(UserType);\n\n// If passed RootQuery, then will be added only `node` field to this type.\n// Via RootQuery.node you may find objects by globally unique ID among all types.\ncomposeWithRelay(queryTC);\n\n// Other types, like User, will be wrapped with middlewares that:\n// - add relay's id field. Field will be added or wrapped to return Relay's globally unique ID.\n// - for mutations will be added clientMutationId to input and output objects types\n// - this type will be added to NodeInterface for resolving via RootQuery.node\ncomposeWithRelay(userTC);\n```\nThat's all!\n\nAll mutations resolvers' arguments will be placed into `input` field, and added `clientMutationId`. If `input` fields already exists in resolver, then  `clientMutationId` will be added to it, rest argument stays untouched. Accepted value via `args.input.clientMutationId` will be transfer to `payload.clientMutationId`, as Relay required it.\n\nTo all wrapped Types with Relay, will be added `id` field or wrapped, if it exist already. This field will return globally unique ID among all types in the following format `base64(TypeName + ':' + recordId)`.  \n\nFor `RootQuery` will be added `node` field, that will resolve by globalId only that types, which you wrap with `composeWithRelay`.\n\nAll this annoying operations is too fatigue to do by hands. So this middleware done all Relay magic implicitly for you.\n\nRequirements\n============\nMethod `composeWithRelay` accept `ObjectTypeComposer` as input argument. So `ObjectTypeComposer` should meet following requirements:\n- has defined `recordIdFn` (function that from object of this type, returns you id for the globalId construction)\n- should have `findById` resolver (that will be used by `RootQuery.node`)\n\nIf something is missing `composeWithRelay` throws error.\n\nCompatible plugins\n==================\n- [graphql-compose-mongoose](https://github.com/graphql-compose/graphql-compose-mongoose)\n\n\nLicense\n=======\n[MIT](https://github.com/graphql-compose/graphql-compose-relay/blob/master/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-compose%2Fgraphql-compose-relay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-compose%2Fgraphql-compose-relay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-compose%2Fgraphql-compose-relay/lists"}