{"id":13989801,"url":"https://github.com/aweary/json-to-graphql","last_synced_at":"2025-07-22T11:31:47.494Z","repository":{"id":66095955,"uuid":"61638820","full_name":"aweary/json-to-graphql","owner":"aweary","description":"Create GraphQL schema from JSON files and APIs","archived":true,"fork":false,"pushed_at":"2020-07-16T20:48:44.000Z","size":119,"stargazers_count":191,"open_issues_count":2,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-29T09:39:03.925Z","etag":null,"topics":["graphql"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"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/aweary.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-06-21T14:07:07.000Z","updated_at":"2024-06-13T01:15:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"a33aeba8-1a3e-4fe7-a3ff-6a37313947ef","html_url":"https://github.com/aweary/json-to-graphql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aweary/json-to-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aweary%2Fjson-to-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aweary%2Fjson-to-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aweary%2Fjson-to-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aweary%2Fjson-to-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aweary","download_url":"https://codeload.github.com/aweary/json-to-graphql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aweary%2Fjson-to-graphql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266483741,"owners_count":23936407,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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"],"created_at":"2024-08-09T13:02:04.777Z","updated_at":"2025-07-22T11:31:45.475Z","avatar_url":"https://github.com/aweary.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# DEPRECATED\n\n```diff\n-- This project is no longer maintained and has fallen severely out of sync with the\n-- GraphQL community. Don't use it at all.\n```\n\n# json-to-graphql\n\n\u003e Generates a GraphQL schema file based on any JSON data\n\n\n## Overview\n\nThis package can take in almost* any kind of JSON data\nand generate a valid GraphQL schema file, including custom\ntypes, lists, nullable and non-nullable fields, and deeply\nnested children.\n\nIf passed an array of JSON data it will use that as \"training\" data to check type consistency and identify\nif fields are nullable or not.\n\n___\n\n* This project is still in pre-release stage and corner cases are sure to arise\n\n## Install\n\n```\n$ npm install --save json-to-graphql\n```\n\n## Usage\n\n\n#### `generateSchema(data: json | Array\u003cjson\u003e): string`\n\nTakes in JSON data (either a singular instance or array) and returns a string containing the schema definitions. You'll likely want to just write this to a file using `fs`.\n\n```js\nimport generateSchema from 'json-to-graphql'\nimport data from './data.json'\n\nconst schema = generateSchema(data)\nfs.writeFile('schema.js', schema, callback)\n```\n\n\n### example\n\nSay you have the following JSON response from an API\n\n```js\n{\n  \"name\": \"brandon\",\n  \"id\": 1,\n  \"favorite_color\": \"teal\",\n  \"job\": {\n    \"type\": \"web developer\",\n    \"years\": 1\n  },\n  \"dogs\": [\"minnie\", \"navi\"]\n}\n```\n\nIt includes strings, ints, nested objects, and arrays. Passing this to `generateSchema` would output the following schema:\n\n```\n\nconst {\n    GraphQLBoolean,\n    GraphQLString,\n    GraphQLInt,\n    GraphQLFloat,\n    GraphQLObjectType,\n    GraphQLSchema,\n    GraphQLID,\n    GraphQLNonNull\n} = require('graphql')\n\n\nconst JobType = new GraphQLObjectType({\n    name: 'job',\n    fields: {\n        type: {\n            description: 'enter your description',\n            type: new GraphQLNonNull(GraphQLString),\n            // TODO: Implement resolver for type\n            resolve: () =\u003e null,\n        },\n        years: {\n            description: 'enter your description',\n            type: new GraphQLNonNull(GraphQLInt),\n            // TODO: Implement resolver for years\n            resolve: () =\u003e null,\n        }\n    },\n});\n\n\nmodule.exports = new GraphQLSchema({\n    query: new GraphQLObjectType({\n        name: 'RootQueryType',\n        fields: () =\u003e ({\n            name: {\n                description: 'enter your description',\n                type: new GraphQLNonNull(GraphQLString),\n                // TODO: Implement resolver for name\n                resolve: () =\u003e null,\n            },\n            id: {\n                description: 'enter your description',\n                type: new GraphQLNonNull(GraphQLID),\n                // TODO: Implement resolver for id\n                resolve: () =\u003e null,\n            },\n            favorite_color: {\n                description: 'enter your description',\n                type: new GraphQLNonNull(GraphQLString),\n                // TODO: Implement resolver for favorite_color\n                resolve: () =\u003e null,\n            },\n            job: {\n                description: 'enter your description',\n                type: new GraphQLNonNull(JobType),\n                // TODO: Implement resolver for job\n                resolve: () =\u003e null,\n            },\n            dogs: {\n                description: 'enter your description',\n                type: new GraphQLNonNull(new GraphQLList(GraphQLString)),\n                // TODO: Implement resolver for dogs\n                resolve: () =\u003e null,\n            }\n        })\n    })\n})\n```\n\nThe only thing the user has to do is hook up the schema to an actual `resolve` function so that it knows how to query different values. In the future this project may include a CLI utility that can generate a resolve utility that wraps\nany JSON API.\n\n\n### Try it out\n\nThe `__tests__` folder currently just contains a small example that you can edit and run. You can change values in `api.js` and see how the generated schema (which is outputed to the console) changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faweary%2Fjson-to-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faweary%2Fjson-to-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faweary%2Fjson-to-graphql/lists"}