未验证 提交 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 { 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',
......
import gql from 'graphql-tag'
import { gql } from '@apollo/client'
export const typeDefs = gql`
type User {
......
......@@ -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",
......
import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloProvider } from '@apollo/client'
import { useApollo } from '../apollo/client'
export default function App({ Component, pageProps }) {
......
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 {
......
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'
......
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 {
......
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'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册