{"id":21073895,"url":"https://github.com/alibasiccoder/easy-gql-loader","last_synced_at":"2025-07-31T00:04:07.006Z","repository":{"id":57155707,"uuid":"256234165","full_name":"AliBasicCoder/easy-gql-loader","owner":"AliBasicCoder","description":"A webpack loader for graphql","archived":false,"fork":false,"pushed_at":"2020-04-30T23:24:06.000Z","size":333,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T03:40:24.922Z","etag":null,"topics":["graphql","webpack"],"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/AliBasicCoder.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":"2020-04-16T14:11:47.000Z","updated_at":"2021-02-23T22:44:28.000Z","dependencies_parsed_at":"2022-08-26T08:30:57.216Z","dependency_job_id":null,"html_url":"https://github.com/AliBasicCoder/easy-gql-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AliBasicCoder/easy-gql-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliBasicCoder%2Feasy-gql-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliBasicCoder%2Feasy-gql-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliBasicCoder%2Feasy-gql-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliBasicCoder%2Feasy-gql-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AliBasicCoder","download_url":"https://codeload.github.com/AliBasicCoder/easy-gql-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliBasicCoder%2Feasy-gql-loader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267962020,"owners_count":24172549,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","webpack"],"created_at":"2024-11-19T19:13:32.155Z","updated_at":"2025-07-31T00:04:06.984Z","avatar_url":"https://github.com/AliBasicCoder.png","language":"TypeScript","readme":"# easy-gql-loader\n\nthe best graphql loader\n\n## Usage\n\nin webpack.config.js add:\n\n```js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [\n      // ...\n      {\n        test: /\\.(gql|graphql)$/,\n        use: {\n          loader: \"easy-gql-loader\",\n        },\n        options: { ...yourOptions }, // options are documented bellow\n      },\n      // ...\n    ],\n  },\n};\n```\n\nnow you could import graphql files\n\n```js\nimport * as hello_world from \"hello_world.gql\";\n\nconsole.log(hello_world);\n// {\n//   queries: { ...your_queries },\n//   mutations: { ...your_mutations },\n//   subscriptions: { ...your_subscriptions }\n// }\n\n// to call a query\nhello_world.queries.myQuery({ ...myArgs }).then(console.log);\n// and the same in mutations\nhello_world.mutations.myMutation({ ...myArgs }).then(console.log);\n\n// with subscriptions\n\nconst subscriber = hello_world.subscriptions\n  .mySubscription({ ...myArgs })\n  .subscribe((data) =\u003e {\n    console.log(\"got some data\", data);\n  });\n\n// after 1500ms unsubscribe\nsetTimeout(() =\u003e {\n  subscriber.unsubscribe();\n  console.log(\"unsubscribing...\");\n}, 1500);\n```\n\n## options\n\nyou declare this options in the webpack.config.js\n\n```js\nmodule: {\n  rules: [\n    // ...\n    {\n      test: /\\.(gql|graphql)$/,\n      use: {\n        loader: \"easy-gql-loader\"\n      },\n      options: { ...yourOptions }\n    },\n    // ...\n  ],\n},\n```\n\n### url\n\ntype: string\n\nthe url for graphql mutation and queries\n\n### webSocketEndPoint\n\ntype: string\n\nthe url for graphql subscriptions\n\n### flat\n\ntype: boolean\n\nflats the exported object\n\nwith flat set to true:\n\n```js\nimport * as hello_world from \"hello_world.gql\";\n\nconsole.log(hello_world);\n// {\n//   ...your_queries,\n//   ...your_mutations,\n//   ...your_subscriptions\n// }\n```\n\n### client\n\ntype: string\n\na path to a js file to be your client\n\nin webpack.config.js add:\n\n```js\noptions: {\n  client: require.resolve(\"./myClient\");\n}\n```\n\nthe type of a client function\n\n```ts\ntype Config = { url: string; webSocketEndPoint: string };\ntype ClientFunction = (\n  config: Config\n) =\u003e (\n  type: \"query\" | \"mutation\" | \"subscription\",\n  query: string,\n  vars: any,\n  opts: any\n) =\u003e any;\n```\n\nin myClient.js:\n\n```js\nmodule.exports = (config) =\u003e {\n  const {\n    // the url is the url of the gql server\n    url,\n    // the websocket url to use for subscriptions\n    webSocketEndPoint,\n  } = config;\n  // type is the type of the operation\n  // query is the query needed for the operation\n  // vars is the query variables\n  // opts is options\n  return (\n    type: \"query\" | \"mutation\" | \"subscription\",\n    query: string,\n    vars: any,\n    opts: any\n  ) =\u003e {\n    // ...your code\n    // NOTE: you must return a promise\n  };\n};\n```\n\n## Licence\n\ncopyright (c) AliBasicCoder 2020\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibasiccoder%2Feasy-gql-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falibasiccoder%2Feasy-gql-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibasiccoder%2Feasy-gql-loader/lists"}