{"id":26674183,"url":"https://github.com/xogroup/joi2gql","last_synced_at":"2025-04-12T06:53:49.415Z","repository":{"id":57281438,"uuid":"101247464","full_name":"xogroup/joi2gql","owner":"xogroup","description":"Conversion of Joi schemas into GraphQL data types","archived":false,"fork":false,"pushed_at":"2022-02-15T14:35:21.000Z","size":78,"stargazers_count":12,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T06:53:44.612Z","etag":null,"topics":["graphql","hapi","javascript","joi","models","nodejs","schema"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xogroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/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":"2017-08-24T02:55:47.000Z","updated_at":"2022-05-20T16:24:16.000Z","dependencies_parsed_at":"2022-09-19T22:14:45.974Z","dependency_job_id":null,"html_url":"https://github.com/xogroup/joi2gql","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xogroup%2Fjoi2gql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xogroup%2Fjoi2gql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xogroup%2Fjoi2gql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xogroup%2Fjoi2gql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xogroup","download_url":"https://codeload.github.com/xogroup/joi2gql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530591,"owners_count":21119595,"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","hapi","javascript","joi","models","nodejs","schema"],"created_at":"2025-03-26T02:17:44.255Z","updated_at":"2025-04-12T06:53:49.389Z","avatar_url":"https://github.com/xogroup.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/xogroup/joi2gql.svg?branch=master)](https://travis-ci.org/xogroup/joi2gql)\n[![npm version](https://badge.fury.io/js/joi2gql.svg)](https://badge.fury.io/js/joi2gql)\n\nEasily convert [Joi](https://github.com/hapijs/joi/) schemas into GraphQL data types.\n\nLead Mainter: [Samuel Joli](https://github.com/Samueljoli)\n\n## Installation \n```Text\nnpm install --save joi2gql\n```\n\u003e graphql-js is listed as a peer dependency. `joi2gql` does not install it's own instance of graphql and instead requires parent module to provide it. This avoids any version collisions.\n\n## Example\n```js\nconst Joi    = require('joi');\nconst Joi2GQL = require('joi2gql');\n\nconst joiSchema = Joi.object().keys({\n    key1: Joi.string(),\n    key2: Joi.number().integer(),\n    key3: Joi.array().items(Joi.string()),\n    key4: Joi.object().keys({\n        subKey1: Joi.string(),\n        subKey2: Joi.number()\n    })\n});\n\nconst GraphQLDataType = Joi2GQL.type(joiSchema);\n```\n\n## Usage\n```js\nconst {\n    Server\n} = require('hapi');\nconst {\n    graphqlHapi \n} = require('apollo-server-hapi');\n\nconst Joi    = require('joi');\nconst Joi2GQL = require('joi2gql');\n\nconst port   = '3000';\nconst host   = 'localhost';\nconst server = new Server();\n\nserver.connection({ port, host });\n\nconst songSchema = Joi.object().keys({\n    artist: Joi.string(),\n    title : Joi.string(),\n    length: Joi.number().integer(),\n});\n\nconst config = {\n    name: 'Song',\n    args: {\n        id: Joi.number().integer()\n    },\n    resolve: (root, args) =\u003e {\n        return {\n            artist: 'Tycho',\n            title : 'Awake',\n            length: 4.43\n        };\n    }\n};\n\nconst Song = Joi2GQL.type(songSchema, config);\nconst rootGQLSchema = {\n    query: {\n        song: Song\n    }\n};\n\nserver.register({\n    register: graphqlHapi,\n    options : {\n        path          : '/graphql',\n        graphqlOptions: {\n            schema: Joi2GQL.schema( rootGQLSchema )\n        }\n    }\n});\n\nserver.start(() =\u003e {\n    if (err) {\n        throw new Error(err);\n    }\n    \n    console.log(`Entering the matrix on port: ${server.info.port}`\n});\n```\n\n## API\nSee the detailed [API](https://github.com/xogroup/joi2gql/blob/master/API.md) reference.\n\n## Contributing\n\nWe love community and contributions! Please check out our [guidelines](http://github.com/xogroup/joi2gql/blob/master/.github/CONTRIBUTING.md) before making any PRs.\n\n## Setting up for development\n\nInstall dependencies and run test.\n\n```\nnpm install \u0026\u0026 npm test\n```\n\n## GraphQL types not yet supported.\n\n- `GraphQLInterfaceType`\n- `GraphQLUnionType`\n\n## Notes\n\nInspired by the [joiql](https://github.com/muraljs/joiql) library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxogroup%2Fjoi2gql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxogroup%2Fjoi2gql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxogroup%2Fjoi2gql/lists"}