{"id":23507406,"url":"https://github.com/ssttevee/js-graphql-jerky","last_synced_at":"2026-05-06T13:01:48.508Z","repository":{"id":69926610,"uuid":"563115189","full_name":"ssttevee/js-graphql-jerky","owner":"ssttevee","description":"Jerky is a schema-first static graphql schema lightweight code generator","archived":false,"fork":false,"pushed_at":"2024-12-06T02:42:53.000Z","size":2039,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T19:15:23.402Z","etag":null,"topics":["cli","codegen","codegenerator","deno","gql","graphql","javascript","js","ts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ssttevee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-11-07T23:51:47.000Z","updated_at":"2024-12-06T02:42:57.000Z","dependencies_parsed_at":"2023-03-03T20:30:33.497Z","dependency_job_id":"d78ace7d-0c0d-4ad3-94e6-a6f3407332fb","html_url":"https://github.com/ssttevee/js-graphql-jerky","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/ssttevee%2Fjs-graphql-jerky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssttevee%2Fjs-graphql-jerky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssttevee%2Fjs-graphql-jerky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssttevee%2Fjs-graphql-jerky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssttevee","download_url":"https://codeload.github.com/ssttevee/js-graphql-jerky/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253768497,"owners_count":21961342,"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":["cli","codegen","codegenerator","deno","gql","graphql","javascript","js","ts","typescript"],"created_at":"2024-12-25T10:18:42.457Z","updated_at":"2026-05-06T13:01:48.434Z","avatar_url":"https://github.com/ssttevee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jerky\n\nJerky is a schema-first static graphql schema lightweight code generator.\n\nThe benefit of such a tool is to remove the requirement of parsing the graphql\nschema at runtime while still employing a schema-first development experience.\nThis is useful for reducing startup or cold start times which is important for\nenvironments where potentially many short-lived instances are spawned in quick\nsuccession such as on serverless platforms.\n\nIn addition to runtime benefits, scalar, resolve, and subscribe functions are\nautomatically linked in the schema, and typescript Types are automatically\ngenerated based on the schema definition.\n\nJerky is made to interoperate with the reference `graphql-js` library and is not\na standalone GraphQL implementation.\n\n## Usage\n\n```\nnpx graphql-jerky\n```\n\nOR\n\n```\ndeno run -A src/command/jerky.ts\n```\n\nBy default, the working directory is searched recursively for `*.graphql` files.\nAll of which are combined into a single schema and rendered to `schema_gen.ts`\nin the same directory.\n\nA path to a directory or file can be passed as the first parameter to limit to\nscope of the search.\n\n### Options\n\n#### --graphql\n\nThe `--graphql` option specifies the module from which the graphql types will be\nimported. Defaults to `graphql`.\n\nThis is sometimes necessary depending on your target platform or runtime. In\nparticular, a node project would probably `graphql` from npm, where as a deno\nproject may use `npm:graphql` instead.\n\n#### --scalars\n\nThe `--scalars` option specifies the module from which scalar functions are\nimported.\n\nThis is used to specify the `serialize`, `parseValue`, and `parseLiteral`\nfunctions that are configure `GraphQLScalarType`s.\n\nFor example, if a custom scalar is defined like this:\n\n```gql\nscalar Date\n```\n\nThe corresponding scalars file could look like this:\n\n```ts\nexport const Date = {\n  serialize(value: Date): string {\n    return value.toISOString();\n  },\n  parseValue(value: unknown): Date {\n    if (typeof value !== \"string\") {\n      throw new Error(\"Date must be a string\");\n    }\n\n    return new globalThis.Date(value);\n  },\n};\n```\n\n#### --resolvers\n\nThe `--resolvers` option specifies a directory of modules from which resolver\nfunctions are imported.\n\nObject and interface types defined in the schema are correlated to a file in the\nspecified directory by name. Within each file, fields of the corresponding type\nare also correlated to the exports by name.\n\nEach export must be a function in the form of\n[`GraphQLFieldResolver`](https://github.com/graphql/graphql-js/blob/e9a81f2ba9020ec5fd0f67f5553ccabe392e95e8/src/type/definition.ts#L879).\n\nFor example, if a schema is defined like this:\n\n```gql\ntype Query {\n  show(id: ID!): Show\n}\n\ntype Show {\n  name: String!\n}\n```\n\nThe corresponding resolvers directory could look like this:\n\n```ts\n// path/to/resolvers/Query.ts\n\nimport { Query } from \"path/to/schema_gen.ts\";\nimport { data, Show } from \"path/to/data.ts\";\n\nexport function show(source: null, { id }: Query.ShowArgs): Show {\n  return data.shows[id];\n}\n```\n\n```ts\n// path/to/resolvers/Show.ts\n\nimport { Show } from \"path/to/data.ts\";\n\nexport function name(source: Show): string {\n  return source.show_name;\n}\n```\n\nAlternatively to a single file containing all field resolvers, for large types\nlike `Query` or `Mutation`, it may be preferrable to break split of field\nresolvers into separate files within a subdirectory of the same name as the\ncorresponding type for better organization.\n\nFor example, if a schema is defined like this:\n\n```gql\ntype Query {\n  show(id: ID!): Show\n  actor(id: ID!): Actor\n}\n```\n\nThe `Query` resolvers may be split up into files like this:\n\n```ts\n// path/to/resolvers/Query/shows.ts\n\nimport { Query } from \"path/to/schema_gen.ts\";\nimport { data, Show } from \"path/to/data.ts\";\n\nexport function show(source: null, { id }: Query.ShowArgs): Show {\n  return data.shows[id];\n}\n```\n\n```ts\n// path/to/resolvers/Query/actors.ts\n\nimport { Query } from \"path/to/schema_gen.ts\";\nimport { Actor, data } from \"path/to/data.ts\";\n\nexport function actors(source: null, { id }: Query.ActorArgs): Actor {\n  return data.actors[id];\n}\n```\n\n#### --subscribers\n\nThe `--subscribers` option specifies the module from which subscribe functions\nare imported. This works in the same way as any particular type from the\n`--resolvers` option, except it is for the `Subscription` type only.\n\n#### --field-directives\n\nThe `--field-directives` option specifies the module from which field directive\nfunctions are imported.\n\nField directive functions work like middleware for field resolvers. They receive\na field resolver function and return a field resolver function. The function\nthat is returned may be a completely new function, or same function that was\npassed in as the parameter. They are invoked once on start, and never again.\n\nFor example, a field directive that ensures that only authorized users may\naccess a field may look like this:\n\n```graphql\ndirective @secure(level: Int!) on FIELD_DEFINITION\n\ntype Mutation {\n  secrets(): String @secure(level: 9001)\n}\n```\n\n```js\nexport function secure(next: GraphQLFieldResolver\u003cany, any\u003e, { level }: SecureDirectiveArgs): GraphQLFieldResolver\u003cany, any\u003e {\n  return (src: any, args: any, ctx: any, info: GraphQLResolveInfo) =\u003e {\n    if (!ctx.authorization) {\n      throw new GraphQLError(\"unauthorized\");\n    }\n\n    if (level \u003e ctx.authorization.level) {\n      throw new GraphQLError(`authorization level ${level} is required`);\n    }\n\n    // src, args, ctx can be mutated here before being passed to the next resolver\n\n    return next(src, args, ctx, info);\n  }\n}\n```\n\n#### --input-directives\n\nThe `--input-directives` option specifies the module from which input and\nargument directive functions are imported.\n\nInput and argument directive functions work like transforms. They receive a\nvalue, do some processing with it, and return a value to be used in place of the\noriginal value. They are invoked every time such a value is received.\n\nFor example, an input directive that requires a value to be an email address may\nlook like this:\n\n```graphql\ndirective @email on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\ntype Mutation {\n  sendMessage(to: String! @email): String\n}\n```\n\n```js\nexport function email(s: string, {}: EmailDirectiveArgs): string {\n  if (!s.includes(\"@\")) {\n    throw new Error(\"must be a valid email\");\n  }\n\n  return s;\n}\n```\n\n## Goals\n\n- Generate runtime-agnostic code\n- Interoperate with `graphql-js`\n- Be easily configurable for any target environment\n- Keep the `graphql-js` version of Jerky independent of that of the target\n  environment\n- Expose APIs for custom integrations\n\n## Non-Goals\n\n- Teaching GraphQL concepts or ideas\n- Extending GraphQL with custom features\n- Overthrowing the Galactic Federation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssttevee%2Fjs-graphql-jerky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssttevee%2Fjs-graphql-jerky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssttevee%2Fjs-graphql-jerky/lists"}