diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-06-14 16:44:21 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-06-14 16:44:21 -0400 |
| commit | b1600adec47a04f60e1da07d94a3ed3906ff5aee (patch) | |
| tree | 828f786da6806d7237ee5cbc5df61e552353b85b /sick-fits/frontend/lib/withData.js | |
| parent | a95e08cd2dd5d7ec0a0412adae02515a5f9cec4f (diff) | |
starter files
Diffstat (limited to 'sick-fits/frontend/lib/withData.js')
| -rw-r--r-- | sick-fits/frontend/lib/withData.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sick-fits/frontend/lib/withData.js b/sick-fits/frontend/lib/withData.js new file mode 100644 index 0000000..755f4c1 --- /dev/null +++ b/sick-fits/frontend/lib/withData.js @@ -0,0 +1,19 @@ +import withApollo from 'next-with-apollo'; +import ApolloClient from 'apollo-boost'; +import { endpoint } from '../config'; + +function createClient({ headers }) { + return new ApolloClient({ + uri: process.env.NODE_ENV === 'development' ? endpoint : endpoint, + request: operation => { + operation.setContext({ + fetchOptions: { + credentials: 'include', + }, + headers, + }); + }, + }); +} + +export default withApollo(createClient); |
