{"id":13725305,"url":"https://github.com/DataArt-Romania/graphql-kimera","last_synced_at":"2025-05-07T20:32:00.441Z","repository":{"id":40782166,"uuid":"255921106","full_name":"lola-tech/graphql-kimera","owner":"lola-tech","description":"Kimera allows you to mock GraphQL schemas with precision","archived":false,"fork":false,"pushed_at":"2023-12-15T05:21:32.000Z","size":4667,"stargazers_count":26,"open_issues_count":20,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-06T09:49:01.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://lola-tech.github.io/graphql-kimera/","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/lola-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-15T13:13:07.000Z","updated_at":"2024-08-16T12:03:23.000Z","dependencies_parsed_at":"2024-01-16T09:52:32.127Z","dependency_job_id":"7e1974dd-3f0f-416d-ba7f-67c65ea52e2b","html_url":"https://github.com/lola-tech/graphql-kimera","commit_stats":{"total_commits":206,"total_committers":10,"mean_commits":20.6,"dds":0.5048543689320388,"last_synced_commit":"9dd84b6f1507a7cdc1a4339eefaa759b3e552089"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lola-tech%2Fgraphql-kimera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lola-tech%2Fgraphql-kimera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lola-tech%2Fgraphql-kimera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lola-tech%2Fgraphql-kimera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lola-tech","download_url":"https://codeload.github.com/lola-tech/graphql-kimera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224645326,"owners_count":17346124,"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-08-03T01:02:18.831Z","updated_at":"2025-05-07T20:31:54.847Z","avatar_url":"https://github.com/lola-tech.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e\n    \u003ca href=\"https://lola-tech.github.io/graphql-kimera/\"\u003eRead the docs\u003ca/\u003e\u0026nbsp;\u0026nbsp;\u0026bull;\u0026nbsp;\u0026nbsp;\u003ca href=\"https://github.com/lola-tech/graphql-kimera/tree/master/packages/graphql-kimera-docs/docs\"\u003eEdit the docs\u003ca/\u003e\n  \u003c/strong\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"300\" src=\"https://raw.githubusercontent.com/lola-tech/graphql-kimera/master/packages/graphql-kimera-docs/static/img/kimera-logo.svg\" alt=\"Kimera logo\"\u003e\n\u003c/p\u003e\n\n# What is Kimera?\n\nKimera is an automocking library for GraphQL that allows you to be very precise about how mocks should be generated.\n\n[![mit](https://img.shields.io/badge/license-MIT-blue)](https://img.shields.io/badge/license-MIT-blue) ![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n![Node.js CI](https://github.com/lola-tech/graphql-kimera/workflows/Node.js%20CI/badge.svg) ![github pages](https://github.com/lola-tech/graphql-kimera/workflows/github%20pages/badge.svg) [![codecov](https://codecov.io/gh/lola-tech/graphql-kimera/branch/master/graph/badge.svg)](https://codecov.io/gh/lola-tech/graphql-kimera) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/graphql-kimera)\n\n## Why?\n\nKimera is useful to:\n\n- **Speed up the prototyping process**. It's very easy to get a mocked server up and running by just updating the schema definition and optionally customizing the mocks providers.\n- **Allow large teams to better coordinate**. Frontend developers can negotiate changes to the schema with the backend developers and then quickly add mocks for the changes in a Kimera mocked version of the server while the backend team gets to implmenting the changes.\n- **Improve testing in front end applications that use GraphQL**. Using Kimera allows one to customize query responses by defining _a single scenario_ as opposed to exhaustively mocking each query response, which is extremely useful for large component trees where queries are used at different levels of the component hierarchy.\n\n## Getting Started\n\nTo install Kimera you can install it via `npm` or `yarn`, it's totally up to you. We're guessing that you'll most likely want Kimera to be a dev dependency.\n\n```\nnpm install --save-dev @lola-tech/graphql-kimera graphql@14\n```\n\nor if you want to use yarn\n\n```\nyarn add --dev @lola-tech/graphql-kimera graphql@14\n```\n\n### Examples\n\nThese examples assume the use of the [example schema we are using for testing](https://github.com/lola-tech/graphql-kimera/blob/master/packages/graphql-kimera/src/__test__/testing.schema.graphql).\n\n#### Basic Example\n\nRunning the `rockets` query will return four rockets, all of type `Shuttle`, with the first being called `Apollo`.\n\n```js\nconst { getExecutableSchema } = require('@lola-tech/graphql-kimera');\n\n// Importing the typeDefs from the `schema.graphql` file...\n\nconst executableSchema = getExecutableSchema({\n  typeDefs,\n  mockProvidersFn: () =\u003e ({\n    scenario: {\n      rockets: [{ name: 'Apollo' }, {}, {}, {}],\n    },\n    builders: {\n      Rocket: () =\u003e ({\n        type: 'Shuttle',\n      }),\n    },\n  }),\n});\n\nconst apollo = new ApolloServer({\n  schema: executableSchema,\n  introspection: true,\n});\n\napollo.listen({ port: 4000 }).then(({ url }) =\u003e {\n  console.log(chalk.green.bold(`🚀 Server ready at ${url}`));\n});\n```\n\n#### Custom query resolvers examples\n\nIf you want to implement filtering in the mocked `rockets` query, you can define\na resolver uing the `mockResolver` function.\n\n```js\nconst {\n  getExecutableSchema,\n  mockResolver,\n} = require('@lola-tech/graphql-kimera');\n\n// Importing the typeDefs from the `schema.graphql` file...\n\nconst executableSchema = getExecutableSchema({\n  typeDefs,\n  mockProvidersFn: () =\u003e ({\n    scenario: {\n      rockets: mockResolver(\n        // Define a resolver factory\n        (mocks) =\u003e (_, { type }) =\u003e {\n          // `mocks` is a store that contains the mocks for the `rockets` query\n          const rockets = mocks.get();\n          return type\n            ? rockets.filter((rocket) =\u003e rocket.type === type)\n            : rockets;\n        },\n        // Optionally define a node scenario\n        [{}, { type: 'Starship' }, { type: 'Starship' }]\n      ),\n    },\n    builders: {\n      Rocket: () =\u003e ({\n        type: 'Shuttle',\n      }),\n    },\n  }),\n});\n\n// Starting your server using the above defined executable schema ....\n```\n\nNow running:\n\n```graphql\nquery {\n  rockets(type: \"Starship\") {\n    name\n    type\n  }\n}\n```\n\nShould return two rockets. Changing the `type` argument to `Shuttle` should return one rocket.\n\n#### Mutations resolvers example\n\n```js\nconst { getExecutableSchema } = require('@lola-tech/graphql-kimera');\n\n// Importing the typeDefs from the `schema.graphql` file...\n\nconst executableSchema = getExecutableSchema({\n  typeDefs,\n  mutationResolversFn: (store, buildMocks) =\u003e ({\n    // Example of how you would use buildMocks to build a node of a specific\n    // type. If the Rocket `type` is omitted from the `input`, the `Shuttle`\n    // value defined in the `Rocket` builder is used.\n    createRocket: (_, { input }) =\u003e {\n      let newRocket = null;\n      // Example of mocking the unhappy path\n      if (input.name !== 'Fail') {\n        newRocket = buildMocks('Rocket', { ...input }, true);\n        store.update({ rockets: [...store.get('rockets'), newRocket] });\n      }\n\n      return {\n        successful: input.name !== 'Fail',\n        rockets: store.get('rockets'),\n      };\n    },\n  }),\n});\n\n// Starting your server using the above defined executable schema ....\n```\n\n## Contributing\n\nThe main purpose of this repository is to continue to evolve Kimera. Development of Kimera happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Kimera.\n\n### Contributing Guide\n\nWe welcome anyone who wants to contribute or provide constructive feedback, no matter the age or level of experience.\n\nPlease read [CONTRIBUTING.md](https://github.com/lola-tech/graphql-kimera/blob/master/CONTRIBUTING.md) for the process for submitting pull requests to us.\n\n### Code of conduct\n\n[Lola Tech](https://www.lola.tech/) has adopted a Code of Conduct that we expect project participants to adhere to. Please read [CODE_OF_CONDUCT.md](https://github.com/lola-tech/graphql-kimera/blob/master/CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.\n\n## Versioning\n\nWe use [lerna](https://lerna.js.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/lola-tech/graphql-kimera/tags).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE.md](https://github.com/lola-tech/graphql-kimera/blob/master/LICENSE.md) file for details.\n\n## Acknowledgements\n\nThe \"Kimera\" name has been inspired from greek mythology - [Chimera](\u003chttps://en.wikipedia.org/wiki/Chimera_(mythology)\u003e), and the logo harkens back to the graphql logo.\n\n## Tips (FAQ)\n\n### Currently, Kimera mocks ID scalars as a string. Perhaps it is possible to mock them with unique values?\n\nAdding different IDs for all types is currently opt in. You can optionally do this as a consumer of Kimera by defining a builder for the ID type in which you can use the [uuid](https://www.npmjs.com/package/uuid) package - [details here](https://github.com/lola-tech/graphql-kimera/issues/64#issuecomment-636201513).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDataArt-Romania%2Fgraphql-kimera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDataArt-Romania%2Fgraphql-kimera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDataArt-Romania%2Fgraphql-kimera/lists"}