{"id":20690754,"url":"https://github.com/lemol/umi-plugin-apollo","last_synced_at":"2025-10-04T03:50:59.030Z","repository":{"id":33073463,"uuid":"150341298","full_name":"lemol/umi-plugin-apollo","owner":"lemol","description":"Apollo graphql plugin for umi","archived":false,"fork":false,"pushed_at":"2022-12-06T15:02:07.000Z","size":5529,"stargazers_count":49,"open_issues_count":25,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-10T11:01:26.501Z","etag":null,"topics":["apollographql","graphql","plugin","react","umi","umijs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemol.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}},"created_at":"2018-09-25T23:31:19.000Z","updated_at":"2024-08-02T15:34:16.000Z","dependencies_parsed_at":"2023-01-14T23:30:18.655Z","dependency_job_id":null,"html_url":"https://github.com/lemol/umi-plugin-apollo","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/lemol%2Fumi-plugin-apollo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemol%2Fumi-plugin-apollo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemol%2Fumi-plugin-apollo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemol%2Fumi-plugin-apollo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemol","download_url":"https://codeload.github.com/lemol/umi-plugin-apollo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249972906,"owners_count":21354084,"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":["apollographql","graphql","plugin","react","umi","umijs"],"created_at":"2024-11-16T23:14:09.807Z","updated_at":"2025-10-04T03:50:54.009Z","avatar_url":"https://github.com/lemol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# umi-plugin-apollo\n\n[![NPM version](https://img.shields.io/npm/v/umi-plugin-apollo.svg?style=flat)](https://npmjs.org/package/umi-plugin-apollo)\n\nUmi plugin for apollo graphql client.\n\n### Install\n\n```bash\n$ yarn add umi-plugin-apollo    # OR npm install --save umi-plugin-apollo\n```\n\n### Setup\n\nHaving setup the `umi-plugin-react`, add the `umi-plugin-apollo` plugin:\n\n```js\n// .umirc.js\n\nexport default {\n  plugins: [\n    ['umi-plugin-react', {\n      routes: {\n        exclude: [\n          /schema\\.(js|jsx|ts|tsx)$/,\n          /resolvers\\.(js|jsx|ts|tsx)$/,\n        ],\n      },\n      // other umi-plugin-react options\n    }],\n    ['umi-plugin-apollo', {/*\n      uri: 'https://my.endpoint.com/graphql',\n      mock: true,\n      hooksImportFrom: 'react-apollo-hooks',\n      options: 'path/to/options/file',\n    */}],\n  ]\n}\n```\n\nDone.\n\n### Options\n\n| name            | type                                    | default                   |\n| --------------- | --------------------------------------- | ------------------------- |\n| uri             | string (required in production)         | `process.env.GRAPHQL_URI` |\n| mock            | string (optional)                       | `process.env.MOCK`        |\n| hooksImportFrom | `'react-apollo-hooks' | 'react-apollo'` | `'react-apollo-hooks'`    |\n| options         | string (optional)                       | `./options/apollo.js`     |\n\n### Options file\n\nYou can create an options file that will be used to customize the creation of ApolloClient.\nDefine this file on the `options` field in the plugin options: \n\n```js\n// .umirc.js\nexport default {\n  plugins: [\n    ['umi-plugin-apollo', {\n      options: 'path/to/options/file',\n    }],\n  ]\n}\n```\n\nThis file can define the following fields:\n\n```js\n// path/to/options/file.js'\n\nexport const cacheOptions = {\n};\n\nexport const httpLinkOptions = {\n};\n\nexport const stateLinkOptions = {\n};\n\nexport const extraLinks = [\n];\n\nexport const clientOptions = {\n};\n\nexport const providerOptions = {\n};\n\nexport const makeCache = undefined; // : ({ cacheOptions }) =\u003e Cache\nexport const makeHttpLink = undefined; // : ({ clientStateLink, remoteLink, httpLinkOptions }) =\u003e ApolloLink\nexport const makeClientStateLink = undefined; // : ({ resolvers, defaults, cache, typeDefs, stateLinkOptions }) =\u003e ApolloLink\nexport const makeLink = undefined; // : ({ clientStateLink, remoteLink, extraLinks }) =\u003e ApolloLink\nexport const makeClient = undefined; // : ({ link, cache, clientOptions }) =\u003e ApolloClient\nexport const makeProvider = undefined; // : ({ client, providerOptions }) =\u003e ReactElement (eg: ({ children }) =\u003e \u003cApolloProvider client={client}\u003e{children}\u003c/ApolloProvider)\n```\n\nPlease, check [this example](https://github.com/lemol/angolans-on-github/blob/master/packages/react-umi-apollo/src/options/apollo.js).\n\n### Generators\n\n```bash\n$ umi generate apollo:page user/index\n```\n\nResult:\n\n```bash\n└── src/\n    ├── pages/\n        ├── user/\n            ├── index.css\n            ├── index.js\n            ├── schema.js\n            └── resolvers.js\n```\n\n### Runtime\n\nRun `yarn start` (or `npm start`) then navigate to `http://localhost:8000/user`.\n\n### Under the hood\n\nCheck the generated files on `src/pages/.umi/apollo`.\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemol%2Fumi-plugin-apollo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemol%2Fumi-plugin-apollo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemol%2Fumi-plugin-apollo/lists"}