{"id":20486850,"url":"https://github.com/rricard/graph-spec","last_synced_at":"2025-12-03T12:02:12.022Z","repository":{"id":57253159,"uuid":"58143375","full_name":"rricard/graph-spec","owner":"rricard","description":"GraphQL assertion and testing made easy","archived":false,"fork":false,"pushed_at":"2016-09-07T09:04:55.000Z","size":13,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T17:12:37.807Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rricard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-05T16:01:53.000Z","updated_at":"2017-07-18T18:58:15.000Z","dependencies_parsed_at":"2022-08-31T22:11:48.734Z","dependency_job_id":null,"html_url":"https://github.com/rricard/graph-spec","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fgraph-spec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fgraph-spec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fgraph-spec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fgraph-spec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rricard","download_url":"https://codeload.github.com/rricard/graph-spec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242063573,"owners_count":20066183,"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-11-15T16:38:54.202Z","updated_at":"2025-12-03T12:02:06.988Z","avatar_url":"https://github.com/rricard.png","language":"JavaScript","readme":"# GraphSpec\n\nGraphQL assertion and testing made easy\n\n[![Build Status](https://travis-ci.org/rricard/graph-spec.svg?branch=master)](https://travis-ci.org/rricard/graph-spec) [![Code Climate](https://codeclimate.com/github/rricard/graph-spec/badges/gpa.svg)](https://codeclimate.com/github/rricard/graph-spec) [![Issue Count](https://codeclimate.com/github/rricard/graph-spec/badges/issue_count.svg)](https://codeclimate.com/github/rricard/graph-spec)\n\n---\n\nGraphSpec is a really simple GraphQL assertion library: it is mainly sugar over\nsomething really simple but repetitive to do otherwise.\n\nUsing GraphSpec, you can take any GraphQL schema, throw a query and have a deep\nvalidation of the query.\n\n## Installation\n\n```\nnpm install --save-dev graph-spec\n```\n\n## Example\n\nIn order to do some classic assertions (using mocha), you can use the default\nasserter:\n\n```javascript\nimport { queryAssert } from \"graph-spec\"\nimport mySchema from \"./schema\"\n\nit(\"should say hello world\", () =\u003e\n  queryAssert(mySchema, `\n    query Test {\n      hello\n    }\n  `, { hello: \"Hello world!\" })\n)\n\nit(\"should be able to greet in french\", () =\u003e\n  queryAssert(mySchema, `\n    query Test($greeting: String!) {\n      hello(greeting: $greeting)\n    }\n  `, { hello: \"Bonjour world!\" }, {\n    variableValues: {greeting: \"Bonjour\"},\n  })\n)\n```\n\nNote that you can pass in the options any of the following GraphQL-js options:\n\n- `rootValue`\n- `contextValue`\n- `variableValues`\n- `operationName`\n\nFor ease of use, you can create your own asserter, able to carry preset options:\n\n```javascript\nimport { createQueryAsserter } from \"graph-spec\"\nimport mySchema from \"./schema\"\n\nconst queryAssert = createQueryAsserter(mySchema, {\n  rootValue: {user: \"le monde\"},\n})\n\nit(\"should say hello world\", () =\u003e\n  queryAssert(`\n    query Test {\n      hello\n    }\n  `, { hello: \"Hello le monde!\" })\n)\n\nit(\"should be able to greet in french\", () =\u003e\n  queryAssert(`\n    query Test($greeting: String!) {\n      hello(greeting: $greeting)\n    }\n  `, { hello: \"Bonjour le monde!\" }, {\n    variableValues: {greeting: \"Bonjour\"},\n  })\n)\n```\n\n## Contributing\n\nYou can clone the repo and send me pull-requests! Be sure the tests, the linter\nand the type checking are all passing:\n\n```\nnpm test\nnpm run lint\nnpm run typecheck\n```\n\n## License\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2016 Robin Ricard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frricard%2Fgraph-spec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frricard%2Fgraph-spec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frricard%2Fgraph-spec/lists"}