{"id":15065896,"url":"https://github.com/gimenete/graphqlize","last_synced_at":"2026-01-02T08:21:06.673Z","repository":{"id":57253739,"uuid":"81227772","full_name":"gimenete/graphqlize","owner":"gimenete","description":"Expose GraphQL services from Plain JavaScript Classes","archived":false,"fork":false,"pushed_at":"2017-02-07T16:31:33.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T08:05:29.413Z","etag":null,"topics":["es2015","graphql","graphql-server"],"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/gimenete.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":"2017-02-07T16:14:59.000Z","updated_at":"2018-09-22T23:03:40.000Z","dependencies_parsed_at":"2022-09-02T11:42:06.150Z","dependency_job_id":null,"html_url":"https://github.com/gimenete/graphqlize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gimenete%2Fgraphqlize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gimenete%2Fgraphqlize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gimenete%2Fgraphqlize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gimenete%2Fgraphqlize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gimenete","download_url":"https://codeload.github.com/gimenete/graphqlize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809887,"owners_count":20351407,"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":["es2015","graphql","graphql-server"],"created_at":"2024-09-25T00:57:05.847Z","updated_at":"2026-01-02T08:21:06.629Z","avatar_url":"https://github.com/gimenete.png","language":"JavaScript","readme":"# Graphqlize\n\nWarning: **Work In Progress**\n\nThis library creates a GraphQL schema from plain JavaScript classes. With this code:\n\n```javascript\nclass Query {\n  /**\n   * List a few comments\n   * @param {number} offset - The offset of...\n   * @param {number} limit - The limit of...\n   * @param {int} limit\n   * @param {int} offset\n   * @return {Comment[]} - The result of...\n   */\n  static list (limit, offset) {\n    return [{\n      text: 'hello world!'\n    }]\n  }\n}\n\nclass Comment {\n  constructor () {\n    /** @type {string!} - The id of a comment */\n    this.id = null\n    /** @type {string} - The content of a comment */\n    this.text = null\n    /** @type {boolean} - Flag that indicates if the comment was deleted */\n    this.deleted = null\n  }\n\n  /**\n   * Gets whatever\n   * @param {context} ctxt\n   * @return {string} - The result of...\n   */\n  whatever (ctxt) {\n    return Promise.resolve(this.text + ' heyyyyyy ' + ctxt.foo)\n  }\n}\n```\n\nJust using `graphqlize`\n\n```javascript\nconst { createSchema } = require('graphqlize')\nconst schema = createSchema(Query, Comment)\n```\n\nYou get a GraphQL schema with this schema:\n\n```\ntype Comment {\n  # The id of a comment\n  id: String!\n\n  # The content of a comment\n  text: String\n\n  # Flag that indicates if the comment was deleted\n  deleted: Boolean\n  whatever: String\n}\n\ntype Query {\n  list(limit: Int, offset: Int): [Comment]\n}\n```\n\nOnce you have the schema you can run a server with it:\n\n```javascript\nvar app = express()\napp.use('/graphql', graphqlHTTP({\n  schema: schema,\n  graphiql: true,\n  context: {}\n}))\n```\n\n## Based on JSDocs\n\nEach class represents a GraphQL `type`. You annotate the classes with standard JSDocs attributes. It supports the following types:\n\n- string: maps to GraphQLString\n- number or float: maps to GraphQLFloat\n- int: maps to GraphQLInt\n- boolean: maps to GraphQLBoolean\n- ID: GraphQLID\n- Custom types\n- Arrays of any previous type\n- not-nullability with `{type!}`\n- using `@param {context}` in a particular field you will get the GraphQL context injected for that argument\n\nYou just need to call `createSchema` passing all the types/classes that you want to expose\n\n```javascript\ncreateSchema(Query, Class2, Class3,...)\n```\n\nThe first class will be the `root` in the schema. Methods act like attributes with arguments. They can be `static` or not.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgimenete%2Fgraphqlize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgimenete%2Fgraphqlize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgimenete%2Fgraphqlize/lists"}