Skip to content

Commit

Permalink
Upgrade Apollo Client to 3.0 in `examples/api-routes-apollo-server-an…
Browse files Browse the repository at this point in the history
…d-client-auth` (#15272)
  • Loading branch information
dstotijn committed Jul 25, 2020
1 parent 574fe0b commit ebe4bb1
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { useMemo } from 'react'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { ApolloClient, InMemoryCache } from '@apollo/client'

let apolloClient

function createIsomorphLink() {
if (typeof window === 'undefined') {
const { SchemaLink } = require('apollo-link-schema')
const { SchemaLink } = require('@apollo/client/link/schema')
const { schema } = require('./schema')
return new SchemaLink({ schema })
} else {
const { HttpLink } = require('apollo-link-http')
const { HttpLink } = require('@apollo/client/link/http')
return new HttpLink({
uri: '/api/graphql',
credentials: 'same-origin',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import gql from 'graphql-tag'
import { gql } from '@apollo/client'

export const typeDefs = gql`
type User {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
"start": "next start"
},
"dependencies": {
"@apollo/react-common": "^3.1.4",
"@apollo/react-hooks": "^3.1.5",
"@apollo/client": "^3.0.2",
"@hapi/iron": "6.0.0",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-http": "^1.5.17",
"apollo-link-schema": "^1.2.5",
"apollo-server-micro": "^2.14.2",
"apollo-utilities": "^1.3.2",
"cookie": "^0.4.1",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.3",
"next": "latest",
"prop-types": "^15.6.2",
"react": "^16.7.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloProvider } from '@apollo/client'
import { useApollo } from '../apollo/client'

export default function App({ Component, pageProps }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import Link from 'next/link'
import gql from 'graphql-tag'
import { useQuery } from '@apollo/react-hooks'
import { gql, useQuery } from '@apollo/client'

const ViewerQuery = gql`
query ViewerQuery {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react'
import { useRouter } from 'next/router'
import Link from 'next/link'
import gql from 'graphql-tag'
import { useMutation, useApolloClient } from '@apollo/react-hooks'
import { gql } from '@apollo/client'
import { useMutation, useApolloClient } from '@apollo/client'
import { getErrorMessage } from '../lib/form'
import Field from '../components/field'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import { useMutation, useApolloClient } from '@apollo/react-hooks'
import gql from 'graphql-tag'
import { gql, useMutation, useApolloClient } from '@apollo/client'

const SignOutMutation = gql`
mutation SignOutMutation {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useState } from 'react'
import { useRouter } from 'next/router'
import Link from 'next/link'
import gql from 'graphql-tag'
import { useMutation } from '@apollo/react-hooks'
import { gql, useMutation } from '@apollo/client'
import { getErrorMessage } from '../lib/form'
import Field from '../components/field'

Expand Down

0 comments on commit ebe4bb1

Please sign in to comment.