{"id":15827646,"url":"https://github.com/defless/graphql-demo","last_synced_at":"2026-05-04T10:40:25.558Z","repository":{"id":102010328,"uuid":"424874492","full_name":"defless/GraphQL-demo","owner":"defless","description":"A GraphQL demo for technological watch.  ","archived":false,"fork":false,"pushed_at":"2021-11-05T13:42:01.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-12T10:26:04.327Z","etag":null,"topics":["api","express","graphql","nodejs","school-project"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/defless.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":"2021-11-05T08:19:30.000Z","updated_at":"2021-11-05T16:05:29.000Z","dependencies_parsed_at":"2023-09-17T07:45:20.131Z","dependency_job_id":null,"html_url":"https://github.com/defless/GraphQL-demo","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.25,"last_synced_commit":"bc86b4ce055134ca7c3022654b1f6c80505fb299"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defless%2FGraphQL-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defless%2FGraphQL-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defless%2FGraphQL-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defless%2FGraphQL-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defless","download_url":"https://codeload.github.com/defless/GraphQL-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246628399,"owners_count":20808105,"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":["api","express","graphql","nodejs","school-project"],"created_at":"2024-10-05T10:08:16.147Z","updated_at":"2026-05-04T10:40:25.527Z","avatar_url":"https://github.com/defless.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL-demo 📊\n\n\u003eThe way you write the query is the way you get the data\n\nA [GraphQL](https://graphql.org/) demo for technological watch.  \n\nInstall dependencies\n```bash\nyarn install\n```\n\nStart the server\n```bash\nyarn start\n```\n\nthen go to http://localhost:4000/graphql\n\n#### GraphQL logic items:\nGraphQL schema\n```\n  type Address {\n    street: String\n    city: City\n  }\n\n  type User {\n    id: ID\n    name: String\n    age: Int\n    friends: [User]\n    address: Address\n  }\n\n  type Query {\n    users: [User]\n    user(id: Int): User\n  }\n```\n\nGraphQL resolver\u003c/br\u003e\n```js\nconst root = {\n   user: ({id}) =\u003e {\n      return users[id];\n   },\n   users: () =\u003e {\n      return users;\n   },\n}\n```\n\n**Get all the informations in one request with query**:\n\u003c/br\u003e\nYou can now try your very first GraphQL query : \n```\nquery{\n  users {\n    name\n    age\n  }\n}\n```\nit allows to get all the users and their name \u0026 age. \n\u003c/br\u003e\nTo get all the users informations and their subsequent fields you can do so:\n```\nquery{\n  users {\n    name\n    age\n    address {\n      city {\n        name\n        code\n        inhabitants\n      }\n      street\n    }\n  }\n}\n```\n\nLet's assume now that you want the data of only one specific user with the the id `0`\n\n```\nquery{\n  user(id: 0) {\n    name\n    age\n    address {\n      city {\n        name\n        code\n        inhabitants\n      }\n      street\n    }\n  }\n}\n```\n\nhere you can see that the user resolver is different from the users one. They do a different job but still on the same API endpoint. \nThis way, we could also get the cities with the corresponding resolver. \n\n\n**Post informations with mutation**:\n\n```\nmutation{\n  newUser(name: \"Name\", age: 45) {\n    id\n    name\n    age\n  }\n}\n```\n\nIt calls the resolver 'newUser', add the user to our list and then return this user to the specified format.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefless%2Fgraphql-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefless%2Fgraphql-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefless%2Fgraphql-demo/lists"}