未验证 提交 ebe4bb1e 编写于 作者: D David Stotijn 提交者: GitHub

Upgrade Apollo Client to 3.0 in `examples/api-routes-apollo-server-and-client-auth` (#15272)

上级 574fe0b5
import { useMemo } from 'react' import { useMemo } from 'react'
import { ApolloClient } from 'apollo-client' import { ApolloClient, InMemoryCache } from '@apollo/client'
import { InMemoryCache } from 'apollo-cache-inmemory'
let apolloClient let apolloClient
function createIsomorphLink() { function createIsomorphLink() {
if (typeof window === 'undefined') { if (typeof window === 'undefined') {
const { SchemaLink } = require('apollo-link-schema') const { SchemaLink } = require('@apollo/client/link/schema')
const { schema } = require('./schema') const { schema } = require('./schema')
return new SchemaLink({ schema }) return new SchemaLink({ schema })
} else { } else {
const { HttpLink } = require('apollo-link-http') const { HttpLink } = require('@apollo/client/link/http')
return new HttpLink({ return new HttpLink({
uri: '/api/graphql', uri: '/api/graphql',
credentials: 'same-origin', credentials: 'same-origin',
......
import gql from 'graphql-tag' import { gql } from '@apollo/client'
export const typeDefs = gql` export const typeDefs = gql`
type User { type User {
......
...@@ -7,18 +7,11 @@ ...@@ -7,18 +7,11 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"@apollo/react-common": "^3.1.4", "@apollo/client": "^3.0.2",
"@apollo/react-hooks": "^3.1.5",
"@hapi/iron": "6.0.0", "@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-server-micro": "^2.14.2",
"apollo-utilities": "^1.3.2",
"cookie": "^0.4.1", "cookie": "^0.4.1",
"graphql": "^14.0.2", "graphql": "^14.0.2",
"graphql-tag": "^2.10.3",
"next": "latest", "next": "latest",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"react": "^16.7.0", "react": "^16.7.0",
......
import { ApolloProvider } from '@apollo/react-hooks' import { ApolloProvider } from '@apollo/client'
import { useApollo } from '../apollo/client' import { useApollo } from '../apollo/client'
export default function App({ Component, pageProps }) { export default function App({ Component, pageProps }) {
......
import { useEffect } from 'react' import { useEffect } from 'react'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import Link from 'next/link' import Link from 'next/link'
import gql from 'graphql-tag' import { gql, useQuery } from '@apollo/client'
import { useQuery } from '@apollo/react-hooks'
const ViewerQuery = gql` const ViewerQuery = gql`
query ViewerQuery { query ViewerQuery {
......
import { useState } from 'react' import { useState } from 'react'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import Link from 'next/link' import Link from 'next/link'
import gql from 'graphql-tag' import { gql } from '@apollo/client'
import { useMutation, useApolloClient } from '@apollo/react-hooks' import { useMutation, useApolloClient } from '@apollo/client'
import { getErrorMessage } from '../lib/form' import { getErrorMessage } from '../lib/form'
import Field from '../components/field' import Field from '../components/field'
......
import { useEffect } from 'react' import { useEffect } from 'react'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { useMutation, useApolloClient } from '@apollo/react-hooks' import { gql, useMutation, useApolloClient } from '@apollo/client'
import gql from 'graphql-tag'
const SignOutMutation = gql` const SignOutMutation = gql`
mutation SignOutMutation { mutation SignOutMutation {
......
import { useState } from 'react' import { useState } from 'react'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import Link from 'next/link' import Link from 'next/link'
import gql from 'graphql-tag' import { gql, useMutation } from '@apollo/client'
import { useMutation } from '@apollo/react-hooks'
import { getErrorMessage } from '../lib/form' import { getErrorMessage } from '../lib/form'
import Field from '../components/field' import Field from '../components/field'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册