{"id":13452004,"url":"https://github.com/ericclemmons/graphql-mock-object","last_synced_at":"2025-03-19T01:31:15.932Z","repository":{"id":57253527,"uuid":"131674831","full_name":"ericclemmons/graphql-mock-object","owner":"ericclemmons","description":"Easily prototype UIs with dynamic GraphQL objects","archived":false,"fork":false,"pushed_at":"2018-06-01T23:52:49.000Z","size":266,"stargazers_count":6,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T19:03:19.535Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ericclemmons.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-01T04:04:47.000Z","updated_at":"2024-11-30T12:18:48.000Z","dependencies_parsed_at":"2022-08-31T22:12:05.853Z","dependency_job_id":null,"html_url":"https://github.com/ericclemmons/graphql-mock-object","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fgraphql-mock-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fgraphql-mock-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fgraphql-mock-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fgraphql-mock-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericclemmons","download_url":"https://codeload.github.com/ericclemmons/graphql-mock-object/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244289672,"owners_count":20429234,"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-07-31T07:01:09.768Z","updated_at":"2025-03-19T01:31:15.653Z","avatar_url":"https://github.com/ericclemmons.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# graphql-mock-object\n\n\u003e Prototype your UI with GraphQL `mock { ... }` objects before defining complex types \u0026 resolvers.\n\nGraphQL works best as a _backend for the frontend (BFF)_ that matches the structure of your UI. `graphql-mock-object` makes it simple for your UI to request data however you'd like. Once you're done prototyping, you can replace mocks with _real_ resolvers and return _real_ data.\n\n### Installation\n\nI recommend saving into `devDependencies`, as prototyping is typically done in `development`, not `production`.\n\n```\nyarn add --dev graphql-mock-object\n# ...or...\nnpm install --save-dev graphql-mock-object\n```\n\nThen add it to your application:\n\n```js\nimport { graphiqlExpress, graphqlExpress } from \"apollo-server-express\"\nimport bodyParser from \"body-parser\"\nimport express from \"express\"\nimport { makeExecutableSchema } from \"graphql-tools\"\n\n// 👇 All the dependencies we need\nimport { mock, MockObject, typeDefs } from \"graphql-mock-object\"\n\nconst schema = makeExecutableSchema({\n  typeDefs: [\n    ...typeDefs, // 👈 All the mock types we're dependent on\n    `type Query { version: String }`, // 👈 Your existing `Query`\n    `extend type Query { mock: MockObject! }`, // 👈 Add `mock` to `Query`\n  ],\n  resolvers: {\n    MockObject, // 👈 This resolves all mock properties\n    Query: {\n      mock, // 👈 This is needed to query `mock`\n      version() {\n        return require(\"../../../package.json\").version\n      },\n    },\n  },\n})\n\n// The rest of your app...\nexport const app = express()\n  .get(\"/\", (req, res) =\u003e res.redirect(\"/graphiql\"))\n  .use(\"/graphql\", bodyParser.json(), graphqlExpress({ schema }))\n  .use(\"/graphiql\", graphiqlExpress({ endpointURL: \"/graphql\" }))\n  .listen(3000, function(err) {\n    if (err) {\n      console.error(err)\n      return\n    }\n\n    console.log(\"Listening at http://localhost:3000\")\n  })\n```\n\n### Author\n\n[Eric Clemmons](https://github.com/ericclemmons/)\n([@ericclemmons](https://twitter.com/ericclemmons))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericclemmons%2Fgraphql-mock-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericclemmons%2Fgraphql-mock-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericclemmons%2Fgraphql-mock-object/lists"}