{"id":13727257,"url":"https://github.com/aaronwlee/oak-graphql","last_synced_at":"2025-07-10T14:30:30.403Z","repository":{"id":37036552,"uuid":"266690092","full_name":"aaronwlee/oak-graphql","owner":"aaronwlee","description":"A simple graphql middleware for oak deno framework.","archived":false,"fork":false,"pushed_at":"2023-08-01T10:13:55.000Z","size":170,"stargazers_count":121,"open_issues_count":10,"forks_count":21,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-17T02:11:26.227Z","etag":null,"topics":["deno","graphql","graphql-middleware"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/aaronwlee.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":"2020-05-25T05:22:05.000Z","updated_at":"2024-09-13T01:00:20.000Z","dependencies_parsed_at":"2024-01-07T21:16:33.060Z","dependency_job_id":null,"html_url":"https://github.com/aaronwlee/oak-graphql","commit_stats":{"total_commits":57,"total_committers":12,"mean_commits":4.75,"dds":0.4736842105263158,"last_synced_commit":"8474a42bb43dbacf3e6d72470b4ee34c5702fd61"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aaronwlee/oak-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronwlee%2Foak-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronwlee%2Foak-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronwlee%2Foak-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronwlee%2Foak-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aaronwlee","download_url":"https://codeload.github.com/aaronwlee/oak-graphql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronwlee%2Foak-graphql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264590683,"owners_count":23633612,"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":["deno","graphql","graphql-middleware"],"created_at":"2024-08-03T01:03:46.572Z","updated_at":"2025-07-10T14:30:30.115Z","avatar_url":"https://github.com/aaronwlee.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Read Me\nHello, it's Aaron.\nFirstly, I'd like to say thanks for using and loving ```oak-graphql.```\n\nUnfortunately, it is nearly impossible to maintain ```oak-graphql.``` because I'm currently serving in the military. It means ```oak-graphql.``` is no longer supported by the author at least until 2022 Nov.\n\nThus, I need some help! If someone wants to maintain it, please don't hesitate to give me an email.\nI want someone can have permission who update and push it to ```deno.land/x```.\n\nI hope y'all are doing well in this bad situation.\n\nRegards\u003cbr\u003e\nAaron Wooseok Lee\u003cbr\u003e\n18-July-2021\u003cbr\u003e\n\u003ca href=\"mailto:aaronwoolee95@gmail.com\"\u003eaaronwoolee95@gmail.com\u003c/a\u003e\n\n\n# Oak-GraphQL\n[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/oak-graphql)\n\nA simple graphql middleware for oak deno framework.\n\n![alt text](https://github.com/aaronwlee/oak_graphql/blob/master/playground.JPG?raw=true \"Oak-GraphQL\")\n\n! Make sure your playground endpoint indicates same as your URL http://localhost:8080/graphql\n\n![alt text](https://github.com/aaronwlee/oak_graphql/blob/master/mustsame.JPG?raw=true \"Oak-GraphQL\")\n\n## Simple run\ndeno run --allow-net --unstable index.ts\n\n## Simple example index.ts\n```ts\n\nimport { Application, Router } from \"https://deno.land/x/oak@v10.0.0/mod.ts\";\nimport { applyGraphQL, gql, GQLError } from \"https://deno.land/x/oak_graphql/mod.ts\";\n\nconst app = new Application();\n// Logger\napp.use(async (ctx, next) =\u003e {\n  await next();\n  const rt = ctx.response.headers.get(\"X-Response-Time\");\n  console.log(`${ctx.request.method} ${ctx.request.url} - ${rt}`);\n});\n\n// Timing\napp.use(async (ctx, next) =\u003e {\n  const start = Date.now();\n  await next();\n  const ms = Date.now() - start;\n  ctx.response.headers.set(\"X-Response-Time\", `${ms}ms`);\n});\n\n\n\nconst types = gql`\ntype User {\n  firstName: String\n  lastName: String\n}\n\ninput UserInput {\n  firstName: String\n  lastName: String\n}\n\ntype ResolveType {\n  done: Boolean\n}\n\ntype Query {\n  getUser(id: String): User \n}\n\ntype Mutation {\n  setUser(input: UserInput!): ResolveType!\n}\n`;\n\nconst resolvers = {\n  Query: {\n    getUser: (parent: any, { id }: any, context: any, info: any) =\u003e {\n      console.log(\"id\", id, context);\n      if(context.user === \"Aaron\") {\n        throw new GQLError({ type: \"auth error in context\" })\n      }\n      return {\n        firstName: \"wooseok\",\n        lastName: \"lee\",\n      };\n    },\n  },\n  Mutation: {\n    setUser: (parent: any, { input: { firstName, lastName } }: any, context: any, info: any) =\u003e {\n      console.log(\"input:\", firstName, lastName);\n      return {\n        done: true,\n      };\n    },\n  },\n};\n\nconst GraphQLService = await applyGraphQL\u003cRouter\u003e({\n  Router,\n  typeDefs: types,\n  resolvers: resolvers,\n  context: (ctx) =\u003e {\n  \t// this line is for passing a user context for the auth\n    return { user: \"Aaron\" };\n  }\n})\n\n\napp.use(GraphQLService.routes(), GraphQLService.allowedMethods());\n\nconsole.log(\"Server start at http://localhost:8080\");\nawait app.listen({ port: 8080 });\n\n```\n\n## TODO\n- [ ] Add cache\n- [ ] Enable the upload\n- [ ] Enable the JSON scalar\n\n## Method\n### gql \n\u003e [GraphQL-tag](https://github.com/apollographql/graphql-tag)\nParsing GraphQL queries\n- `gql` A JavaScript template literal tag that parses GraphQL query strings into the standard GraphQL AST.\n\n### GQLError\nAn error handler\n\u003e Example\n```ts\nthrow new GQLError(\"string\");\nor\nthrow new GQLError({type: \"General error\", detail: \"somthing critical!\"});\n```\n\n### applyGraphQL\nA Generator which based Attain Router class creates some middlewares for supporting the GraphQL.\n\u003e Options\n- Router: oak Router module \u003cbr /\u003eDue to the version incompatible issue mentioned by (avalero)[https://github.com/avalero], I've decoupled the Router. Thanks :)\n- path?: string \u003cbr /\u003e A target path that handles the GraphQL post request (__*optional__: default as `/graphql`)\n- typeDefs: any \u003cbr /\u003e generated type tags by the `gql`\n- resolvers: any \u003cbr /\u003e An object that handles the queries and mutations\n```ts\nconst resolvers = {\n  Query: {\n    getUser: (parent: any, {id}: any, context: any, info: any) =\u003e {\n      // ...query handling function here\n    },\n  },\n  Mutation: {\n    addUser: (parent: any, {firstName, lastName}: any, context: any, info: any) =\u003e {\n      // ...add user codes here\n    },\n  }\n}\n```\n\u003e The resolvers will be received these four parameters\n\u003e - parent: The return value of the resolver for this field's parent\n\u003e - args: An object that contains all GraphQL arguments provided for this field.\n\u003e - context: An object shared across all resolvers that are executing for a particular operation.\n\u003e - info: Contains information about the operation's execution state, including the field name, the path to the field from the root, and more.\n- context?: (ctx) =\u003e any \u003cbr /\u003e Send any objects to each resolver (__*optional__)\n- usePlayground?: boolean; \u003cbr /\u003e enable the playground at get method (__*optional__: default as `true`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronwlee%2Foak-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaronwlee%2Foak-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronwlee%2Foak-graphql/lists"}