{"id":14384614,"url":"https://github.com/groupon/swagql","last_synced_at":"2025-08-23T17:33:02.360Z","repository":{"id":34192528,"uuid":"170366088","full_name":"groupon/swagql","owner":"groupon","description":"Create a GraphQL schema from swagger spec","archived":false,"fork":false,"pushed_at":"2023-01-07T04:01:56.000Z","size":717,"stargazers_count":45,"open_issues_count":9,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-29T11:12:01.287Z","etag":null,"topics":["graphql","javascript","nodejs","openapi","swagger"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/groupon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-12T18:05:22.000Z","updated_at":"2024-09-26T00:55:20.000Z","dependencies_parsed_at":"2023-01-15T05:11:53.898Z","dependency_job_id":null,"html_url":"https://github.com/groupon/swagql","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groupon%2Fswagql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groupon%2Fswagql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groupon%2Fswagql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/groupon%2Fswagql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/groupon","download_url":"https://codeload.github.com/groupon/swagql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230716590,"owners_count":18269799,"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":["graphql","javascript","nodejs","openapi","swagger"],"created_at":"2024-08-28T18:01:30.991Z","updated_at":"2024-12-21T12:30:46.416Z","avatar_url":"https://github.com/groupon.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![nlm-github](https://img.shields.io/badge/github-groupon%2Fswagql%2Fissues-F4D03F?logo=github\u0026logoColor=white)](https://github.com/groupon/swagql/issues)\n![nlm-node](https://img.shields.io/badge/node-%3E%3D10.13-blue?logo=node.js\u0026logoColor=white)\n![nlm-version](https://img.shields.io/badge/version-1.4.0-blue?logo=version\u0026logoColor=white)\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/433909/52972858-ff0e6d00-3370-11e9-9188-6b3672acec27.jpg\" width=\"400\" height=\"440\"\u003e\n\u003c/div\u003e\n\nBuild a GraphQL schema from a given Swagger or Open API specification.\n\n## Install\nTo install swagql as devDependency run:\n```bash\nnpm i -D swagql\n```\n\n## Usage\n```bash\ncat swagger.yml | npx swagql [-p \u003cbabel-plugin1-path\u003e,\u003cbabel-plugin2-path\u003e] [-n NamePrefix_]\u003e schema.js\n```\n\nInput swagger schema can be in YAML or JSON format. The generated schema exports\na `schema` object and two symbols `FETCH` and `VERIFY_AUTH_STATUS`. These\nsymbols should reside in the `context` used while creating the GraphQL server.\n\nThe definition of `VERIFY_AUTH_STATUS` symbol is optional. It is used to check\nthe authorization status for given request and swagger auth config. If a given\nrequest does not satisfy the required auth status, you can throw an auth error\nfrom this function. `requestContext` can be used to hold the information about\nthe current request, such as the request object itself.\n\nIn the case where you are merging multiple schemas, you may wish to have all\nof the methods and types be unique, and can pass the `--name-prefix` (or `-n`)\nflag to prepend the given string to all of the above.\n\n```js\nconst { schema, FETCH, VERIFY_AUTH_STATUS } = require(pathToSchema);\n\nfunction verifyAuthStatus(requestContext, authConfig) {\n    // verify if current request satisfies authConfig for the given endpoint.\n    // if not, throw an auth error.\n}\nconst context = {\n  [FETCH]: apiClient.fetch,\n  [VERIFY_AUTH_STATUS]: verifyAuthStatus.bind(null, request),\n};\n```\n\nUse schema and context in your app\n```js\nconst { graphql } = require('graphql');\n\ngraphql(schema, query, context)\n  .then(result =\u003e console.log(result));\n```\n\n## Pagination\n\nIf given REST API response includes lists, we need to add page info and edge\nconnection cursors to handle pagination in GraphQL.\n\nTo handle this, the generated schema looks for `convertArrayToConnection` and\n`parseCursorOptions` function definitions in `./array-to-connection.js`. SwagQL\nprovides a default implementation for array-to-connection. If your APIs return\npagination information in the response, the default implementation can be used\nas follows:\n\n```js\n// array-to-connection.js\nmodule.exports = require('swagql/array-to-connection');\n```\n\nIf your API responses handle pagination differently, you may have to customize\narray-to-connection implementation.\n\n## Acknowledgements\n\n`test/fixtures/petstore.json` is taken from https://petstore.swagger.io/v2/swagger.json\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgroupon%2Fswagql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgroupon%2Fswagql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgroupon%2Fswagql/lists"}