{"id":15007871,"url":"https://github.com/schamane/graphql-middleware","last_synced_at":"2026-04-02T01:58:46.770Z","repository":{"id":140780298,"uuid":"402689136","full_name":"schamane/graphql-middleware","owner":"schamane","description":"Middleware helper for graphql","archived":false,"fork":false,"pushed_at":"2022-10-26T08:54:35.000Z","size":768,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T03:32:05.219Z","etag":null,"topics":["apollo-server-express","express","extension","graphql","middleware","npmjs","subscriptions","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/schamane.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-03T07:47:01.000Z","updated_at":"2021-09-10T20:05:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ca46271-8821-4ba1-aa2f-28e90d34e17a","html_url":"https://github.com/schamane/graphql-middleware","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"275b14cf7e48fcb43ed2aea0461e2ab52f47bf76"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schamane%2Fgraphql-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schamane%2Fgraphql-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schamane%2Fgraphql-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schamane%2Fgraphql-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schamane","download_url":"https://codeload.github.com/schamane/graphql-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243158973,"owners_count":20245669,"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":["apollo-server-express","express","extension","graphql","middleware","npmjs","subscriptions","websocket"],"created_at":"2024-09-24T19:14:15.132Z","updated_at":"2025-12-26T05:24:09.341Z","avatar_url":"https://github.com/schamane.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graphql Middleware\n\n@schamane/graphql-middleware\n\nmiddleware for [Apollo grapqhl server](https://www.apollographql.com/docs/apollo-server/) =\u003e 3.3.0 with websocket support for subscriptions based on express/polka\n\n## Todo\n\n- Authentication get working for context with WS and Graphql (typings)\n\n## Add dependancy to project\n\n```bash\nnpm i @schamane/@schamane/graphql-middleware\n```\n\n## Define app middleware\n\n```ts\nimport { ApolloServer } from 'apollo-server-express';\nimport { TestBL } from '../bl/test';\nimport * as schemasDefs from '../schemas';\nimport { makeSchema, createGraphQlServer, initSubscriptionWSWihtCompatibility, DataSources, GrapqhContext } from '@schamane/graphql-middleware';\nimport type { Server } from 'http';\n\n\nconst schema = makeSchema(schemasDefs as any) as any;\n\nconst createDataSources = (): DataSources\u003cGrapqhContext\u003e =\u003e ({\n  testApi: new TestBL()\n});\n\nexport const initGraphQl = async (app: any): Promise\u003cApolloServer\u003e =\u003e {\n  const dataSources = createDataSources;\n\n  const graphqlServer = createGraphQlServer(app, {\n    schema,\n    dataSources,\n  }, {path: `/graphql`,});\n\n  return graphqlServer;\n};\n\nexport const initSubscriptions = (server: Server) =\u003e {\n  const schema = makeSchema(schemasDefs as any) as any;\n  return initSubscriptionWSWihtCompatibility(server, schema);\n}\n```\n\n## Use middleware with express\n\n```ts\nimport express, { Application } from 'express';\n\nconst PORT: string = process.env.PORT || '8081';\n\nconst app: Application = express();\n\nconst serverInitialize = async () =\u003e {\n    app.get('/', (_, res) =\u003e {\n    res.send({ msg: 'set api version for request' });\n  });\n\n  await initGraphQl(app);\n  const server = app.listen(PORT, async () =\u003e {\n    initSubscriptions(server);\n    console.info(`Listening to port ${PORT}`);\n  });\n  return server;\n};\n\nexport const server = serverInitialize();\n\n```\n\n## Use middleware with polka\n\n```ts\nimport polka from 'polka';\nimport type { Polka } from 'polka';\n\nconst PORT: string = process.env.PORT || '8081';\n\nconst app: Polka = polka();\n\nconst serverInitialize = async () =\u003e {\n    app.get('/', (_, res) =\u003e {\n    res.send({ msg: 'set api version for request' });\n  });\n\n  await initGraphQl(app as any);\n  const server = app.listen(PORT, async () =\u003e {\n    initSubscriptions(server);\n    console.info(`Listening to port ${PORT}`);\n  }).server;\n  return server;\n};\n\nexport const server = serverInitialize();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschamane%2Fgraphql-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschamane%2Fgraphql-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschamane%2Fgraphql-middleware/lists"}