{"_id":"@commbuds/next-with-apollo-hooks","_rev":"1-886c8d40c4b54c85f36ce7d47b51141f","name":"@commbuds/next-with-apollo-hooks","dist-tags":{"latest":"3.3.2"},"versions":{"3.3.2":{"name":"@commbuds/next-with-apollo-hooks","private":false,"version":"3.3.2","description":"Apollo HOC for Next.js","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"fix":"tslint -p tsconfig.json --fix","tslint":"tslint -c tslint.json -p tsconfig.json -t codeFrame","jest":"jest","test":"jest --coverage","build-ts":"tsc","watch":"tsc -w","build":"npm run build-ts","prepublishOnly":"npm run build && npm test"},"author":{"name":"lfades"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/gradepotential/next-with-apollo.git"},"bugs":{"url":"https://github.com/gradepotential/next-with-apollo/issues"},"prettier":{"singleQuote":true},"peerDependencies":{"react":"^15.0.0 || ^16.0.0","next":"^6.0.0 || ^7.0.0","react-apollo-hooks":"^0.4.0"},"devDependencies":{"@types/graphql":"14.0.3","@types/jest":"^23.3.10","@types/next":"^7.0.5","@types/node":"^10.12.18","@types/prop-types":"^15.5.8","@types/react":"^16.7.17","apollo-client":"^2.4.8","graphql":"14.0.2","jest":"^23.6.0","next":"^7.0.2","prettier":"^1.16.4","react":"^16.6.3","ts-jest":"^23.10.5","tslint":"^5.12.0","tslint-config-prettier":"^1.17.0","tslint-eslint-rules":"^5.4.0","tslint-plugin-prettier":"^2.0.1","typescript":"^3.2.2"},"dependencies":{"@types/react-dom":"^16.0.11","isomorphic-unfetch":"^3.0.0","prop-types":"^15.6.2","react-apollo-hooks":"^0.4.0","react-dom":"^16.6.3"},"gitHead":"d0b1676b7684646b8cb9a2228a1cb3b85226be8c","homepage":"https://github.com/gradepotential/next-with-apollo#readme","_id":"@commbuds/next-with-apollo-hooks@3.3.2","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"ecwyne","email":"ecwyne@gmail.com"},"dist":{"integrity":"sha512-tnhHTEgrk/T5L9PI4Rz/ccFa2bqdtQlw4r0DHQ5+LO0OOsquf4A171AwOGCPIq1lV8qoNWH+keZOselswYWzYg==","shasum":"7ef587e8d3e8661478ebdf0da948e78b365d8107","tarball":"https://registry.npmjs.org/@commbuds/next-with-apollo-hooks/-/next-with-apollo-hooks-3.3.2.tgz","fileCount":29,"unpackedSize":36122,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcbyaHCRA9TVsSAnZWagAAiR4QAKCT1pHpR64DiOSAmnSQ\nhH7HqZ7S9SiTLyoC5JqegNV8vuFspPM4FB2v4BYkCZIc6SMwnwvRvOxfdUdF\nZI9BFJ3diLrNupRs516No4IULhtjpSjHOWbQZrPx7/2386poL2Av8Gr0mb+B\nz7fj3ZE/KOjGh4qYTg8xsYDSh5jTKmuIEynaDNObh4U3EgSjcDy5FALi2I7z\nY9uSnEz9EBNhPxYzxG9MjNpLMZKAIFRuFSZOnqt5cfnWCxZICYVJ3DxJqXzF\nSw5WliD99/+lriUUVqxjQ1oOLmPOztgC8D76p34P3tPDf0eXIftkhDggkudV\nFeeAt98Z8auhQnsJBJk7NXz+sWHkauP6j9qE/xWvqwCD22EOrrQxViITEOSZ\nAcpvC/gb7NOlzw+tR36Z2KOGyt2MYWCAc6Xw19D7oZwwYhHPgHqMcXI2m5SN\nPPcqgEzDKwUieNvMVRwsoP82JipUy+GiomN2W81CxcoM0eEwajlQPOYw3Sdj\nQihxcbVFyNtBLnyvslg/NmYAwddqhMxBvzKtqQCTed1umZvQ7DCqcAme8RNL\ndB+RXT/WCm5g2cqSJ6Us/UwViBp82V2j6KLphsUkjpM89n2qQm+/04SwJO3l\n2wKdJIVxC8sbFzIj/zFSYUTv3YMjNDjb+syoRNHW1Z9tODsyM0Y9ISFOT1q5\nth+J\r\n=upEa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC8JuDwwQdrqIfkIuV76lheqUQgFHHXoQRMfw1FOEetHAiEAxJ4pZ1n+aHRVNBTFzaDoHZUCWy0fAdP0opIGoeZ1bec="}]},"maintainers":[{"name":"ecwyne","email":"ecwyne@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-with-apollo-hooks_3.3.2_1550788231134_0.9096097867497646"},"_hasShrinkwrap":false}},"time":{"created":"2019-02-21T22:30:31.063Z","3.3.2":"2019-02-21T22:30:31.234Z","modified":"2022-04-05T00:24:50.380Z"},"maintainers":[{"name":"ecwyne","email":"ecwyne@gmail.com"}],"description":"Apollo HOC for Next.js","homepage":"https://github.com/gradepotential/next-with-apollo#readme","repository":{"type":"git","url":"git+https://github.com/gradepotential/next-with-apollo.git"},"author":{"name":"lfades"},"bugs":{"url":"https://github.com/gradepotential/next-with-apollo/issues"},"license":"MIT","readme":"# next-with-apollo\n\nApollo HOC for Next.js, this docs are for Next > 6, for Next < 5  go [here](./README_v1.md) and use the version 1.0\n\n## How to use\n\nInstall the package with npm\n\n```sh\nnpm install next-with-apollo\n```\n\nor with yarn\n\n```sh\nyarn add next-with-apollo\n```\n\nCreate the HOC using a basic setup and [apollo-boost](https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost)\n\n> Note: [apollo-boost](https://github.com/apollographql/apollo-client/tree/master/packages/apollo-boost) is used in this example because is the fastest way to create an `ApolloClient`, but is not required.\n>\n> Previously this package had some configs to create an `ApolloClient`, those were removed but you can see an example of how to create the same `ApolloClient` by yourself [here](https://github.com/lfades/next-with-apollo/issues/13#issuecomment-390289449).\n```js\n// lib/withApollo.js\nimport withApollo from 'next-with-apollo'\nimport ApolloClient, { InMemoryCache }  from 'apollo-boost'\nimport { GRAPHQL_URL } from '../configs'\n\nexport default withApollo(({ ctx, headers, initialState }) => (\n  new ApolloClient({\n    uri: GRAPHQL_URL,\n    cache: new InMemoryCache().restore(initialState || {})\n  })\n))\n```\n\n> `withApollo` accepts a function that receives `{ ctx, headers }` or `{ initialState }` and returns an `ApolloClient`\n\nWrap Next's `App` in `pages/_app.js`\n\n```js\nimport App, { Container } from 'next/app'\nimport { ApolloProvider } from 'react-apollo'\nimport withApollo from '../lib/withApollo'\n\nclass MyApp extends App {\n  render() {\n    const { Component, pageProps, apollo } = this.props;\n\n    return (\n      <Container>\n        <ApolloProvider client={apollo}>\n          <Component {...pageProps} />\n        </ApolloProvider>\n      </Container>\n    );\n  }\n}\n\nexport default withApollo(MyApp)\n```\n\nNow every page in `pages/` can use anything from `react-apollo`!. Pages will have access to the `ApolloClient` too: `getInitialProps({ apolloClient })`\n\n**withApollo** can also receive some options as second parameter:\n\n| Key | Type | Default | Note |\n| --- | ---- | ------- | ---- |\n| `getDataFromTree` |  `string` | `always` | Should the apollo store be hydrated before the first render ?, allowed values are `always`, `never` or `ssr` (don't hydrate on client side navigation)\n\nUsage example:\n\n```js\nexport default withApollo(\n  () => new ApolloClient({ uri: GRAPHQL_URL }),\n  {\n    getDataFromTree: 'always'\n  }\n)\n```\n\n## How it works\n\n`next-with-apollo` will create a Higher-Order Component (HOC) with your configuration that can be used in `pages/_app` to wrap an `ApolloClient` to any Next page, it will also fetch your queries before the first page load to [hydrate the store](https://dev-blog.apollodata.com/how-server-side-rendering-works-with-react-apollo-20f31b0c7348).\n","readmeFilename":"README.md"}