{"id":15644804,"url":"https://github.com/egoist/graphql-aot","last_synced_at":"2025-08-03T13:14:12.125Z","repository":{"id":45274904,"uuid":"131868740","full_name":"egoist/graphql-aot","owner":"egoist","description":"Run GraphQL query ahead of time. (i.e. at build time)","archived":false,"fork":false,"pushed_at":"2021-12-25T14:43:01.000Z","size":109,"stargazers_count":54,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-07T01:44:40.468Z","etag":null,"topics":["babel","graphql","loader","webpack"],"latest_commit_sha":null,"homepage":"","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/egoist.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":"2018-05-02T15:14:43.000Z","updated_at":"2024-05-20T11:10:16.000Z","dependencies_parsed_at":"2022-08-31T22:11:11.480Z","dependency_job_id":null,"html_url":"https://github.com/egoist/graphql-aot","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/egoist/graphql-aot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fgraphql-aot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fgraphql-aot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fgraphql-aot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fgraphql-aot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/graphql-aot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fgraphql-aot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266393620,"owners_count":23922424,"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-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["babel","graphql","loader","webpack"],"created_at":"2024-10-03T12:02:27.378Z","updated_at":"2025-07-21T22:36:42.861Z","avatar_url":"https://github.com/egoist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# graphql-aot\n\n[![NPM version](https://img.shields.io/npm/v/graphql-aot.svg?style=flat)](https://npmjs.com/package/graphql-aot) [![NPM downloads](https://img.shields.io/npm/dm/graphql-aot.svg?style=flat)](https://npmjs.com/package/graphql-aot) [![CircleCI](https://circleci.com/gh/egoist/graphql-aot/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/graphql-aot/tree/master)  [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026style=flat)](https://github.com/egoist/donate) [![chat](https://img.shields.io/badge/chat-on%20discord-7289DA.svg?style=flat)](https://chat.egoist.moe)\n\n## Install\n\n```bash\nyarn add graphql-aot\n```\n\n## Usage\n\nIf you only want to work with the `import` statement, you will only need the webpack loader:\n\n📝 __webpack.config.js__:\n\n```js\nmodule.exports = {\n  entry: './index.js',\n  module: {\n    rules: [\n      {\n        test: /\\.gql$/,\n        loader: 'graphql-aot/loader',\n        options: {\n          defaultClientOptions: {\n            uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn'\n          }\n        }\n      }\n    ]\n  }\n}\n```\n\n📝 __query.gql__:\n\n```graphql\n{\n  allPosts (first: 5) {\n    id\n    title\n  }\n}\n```\n\n📝 __index.js__:\n\n```js\nimport data from './query.gql'\n\nconsole.log(data.allPosts)\n```\n\nIf you want to use inline graphql tag, you will __also__ need the babel plugin:\n\n📝 __.babelrc.js__:\n\n```js\nmodule.exports = {\n  plugins: [\n    require.resolve('graphql-aot/babel')\n  ]\n}\n```\n\n📝 __index.js__:\n\n```js\nconst { allPosts } = graphql`\n{\n  allPosts (first: 5) {\n    id\n    title\n  }\n}\n`\n\nconsole.log(allPosts)\n```\n\n## API\n\n### loaderOptions\n\n#### defaultClientOptions\n\n[Options for the default Apollo client](https://www.apollographql.com/docs/react/essentials/get-started.html#configuration).\n\n#### client\n\nProvide your own Apollo client instance.\n\n#### getVariables\n\n- __Type__: `function`\n\nA function to get the variables you want to use with the [`client.query()`](https://www.apollographql.com/docs/react/api/apollo-client.html#ApolloClient.query) call.\n\nThe signature is: `loaderContext =\u003e any`\n\n### babelOptions\n\n#### tagName\n\n- __Type__: `string`\n- __Default__: `graphql`\n\n#### importFrom\n\n- __Type__: `string`\n- __Default__: `undefined`\n\nEnsure the tagged template literal identifier is imported from a module.\n\n```js\nimport { gql } from 'a-module'\n\nconst data = gql`query { id }`\n```\n\nThe above code will only work when you have following config for the babel plugin:\n\n```js\n{\n  importFrom: 'a-module',\n  tagName: 'gql'\n}\n```\n\n#### removeImportStatement\n\n- __Type__: `boolean`\n- __Default__: `true` when you set `importFrom` to a module name\n\nRemove relevant import statement if necessary.\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n\n## Author\n\n**graphql-aot** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.\u003cbr\u003e\nAuthored and maintained by egoist with help from contributors ([list](https://github.com/egoist/graphql-aot/contributors)).\n\n\u003e [github.com/egoist](https://github.com/egoist) · GitHub [@egoist](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fgraphql-aot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Fgraphql-aot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fgraphql-aot/lists"}