{"id":18819578,"url":"https://github.com/jdgabriel/learning-graphql-relay","last_synced_at":"2026-04-17T08:02:23.960Z","repository":{"id":246252707,"uuid":"820451784","full_name":"jdgabriel/learning-graphql-relay","owner":"jdgabriel","description":"Learning graphql relay in NodeJS basic properties, non database connection","archived":false,"fork":false,"pushed_at":"2024-06-26T17:29:48.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-01T03:16:03.799Z","etag":null,"topics":["apollo-server","graphql","graphql-relay","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdgabriel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-26T13:48:33.000Z","updated_at":"2024-09-27T22:08:20.000Z","dependencies_parsed_at":"2024-06-26T22:26:38.669Z","dependency_job_id":null,"html_url":"https://github.com/jdgabriel/learning-graphql-relay","commit_stats":null,"previous_names":["jdgabriel/learning-graphql-relay"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jdgabriel/learning-graphql-relay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdgabriel%2Flearning-graphql-relay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdgabriel%2Flearning-graphql-relay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdgabriel%2Flearning-graphql-relay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdgabriel%2Flearning-graphql-relay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdgabriel","download_url":"https://codeload.github.com/jdgabriel/learning-graphql-relay/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdgabriel%2Flearning-graphql-relay/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31920518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["apollo-server","graphql","graphql-relay","nodejs"],"created_at":"2024-11-08T00:23:52.075Z","updated_at":"2026-04-17T08:02:23.891Z","avatar_url":"https://github.com/jdgabriel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API GraphQL with Relay\n\nLearning graphql relay in NodeJS basic properties, non database connection\n\n## Post Type\n\n```ts\nexport const PostType = new GraphQLObjectType({\n  name: \"Post\",\n  description: \"Post type properties\",\n  fields: () =\u003e ({\n    id: globalIdField(\"Posts\"), // \u003c-- Global id for use in relay\n    title: {\n      type: GraphQLString,\n      resolve: (post) =\u003e post.title,\n    },\n    body: {\n      type: GraphQLString,\n      resolve: (post) =\u003e post.body,\n    },\n  }),\n  interfaces: [nodeInterface], // \u003c- Node Interface\n});\n\n// Relay connection and edge\nexport const { connectionType: PostConnection, edgeType: PostEdge } = connectionDefinitions({\n  nodeType: PostType,\n});\n```\n\n## Node Interface\n\n```ts\nexport const { nodeInterface, nodeField } = nodeDefinitions(\n  (globalId) =\u003e {\n    const { type, id } = fromGlobalId(globalId);\n    /**\n     * type -\u003e Type of global id (e.g: Post)\n     * id   -\u003e Identification id (e.g: uuid)\n     * Search for data where contains equal id in database or local array\n     */\n  },\n  (obj) =\u003e {\n    /**\n     * obj    -\u003e Contains all properties returned from globalId function\n     * return -\u003e Return type of data (e.g: Post)\n     */\n    return \"Post\";\n  }\n);\n```\n\n## Query\n\n```ts\nexport const QueryType = new GraphQLObjectType({\n  name: \"Query\",\n  description: \"Query type root\",\n  fields: () =\u003e ({\n    node: nodeField // \u003c-- Add Node Resolver query,\n    post: {\n      type: new GraphQLNonNull(PostConnection), // \u003c-- PostConnection Relay\n      args: connectionArgs,\n      resolve: async (_, args, ctx) =\u003e {\n        const data = await PostLoader.loadAll();\n        return connectionFromArray(data, args); // \u003c-- Pagination Relay\n      },\n    },\n  }),\n});\n```\n\n## Mutation\n\n```ts\nexport const MutationType = new GraphQLObjectType({\n  name: \"Mutation\",\n  description: \"Mutation types\",\n  fields: () =\u003e ({\n    // Add all mutations functions\n  }),\n});\n```\n\n## Server Schema\n\n```ts\nexport const schema = new GraphQLSchema({\n  query: QueryType,\n  mutation: MutationType,\n  // subscription: SubscriptionType\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdgabriel%2Flearning-graphql-relay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdgabriel%2Flearning-graphql-relay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdgabriel%2Flearning-graphql-relay/lists"}