首页 > 解决方案 > 尝试 gatsby-theme-apollo - 服务器不可见

问题描述

入门时遇到问题 https://github.com/apollographql/gatsby-theme-apollo/tree/master/packages/gatsby-theme-apollo

采取的步骤:

>     gatsby new atest
>     cd atest
>     npm install gatsby-theme-apollo @apollo/client
>     make new directory: atest/src/gatsby-theme-apollo
>     make new file in directory: client.js
>     copy paste content from instructions without change:

    import fetch from 'isomorphic-fetch';
    import {ApolloClient, HttpLink, InMemoryCache} from '@apollo/client';

const client = new ApolloClient({
      cache: new InMemoryCache(),
      link: new HttpLink({
        uri: 'https://api.spacex.land/graphql/',
        fetch
      })
    })

在浏览器中:检查 spacex api 是否启动终端:gatsby 开发浏览器:导航到 localhost:8000/___graphql

查询可用于站点 OK 但是,没有可用的 spacex 查询。缺少任何步骤吗?(在 ubuntu 18.04 节点 12.14.1、gatsby 2.19.7 上)

标签: gatsbyreact-apollo

解决方案


不是问题:只有在连接服务器端 graphql 时,服务器才会与其他 gatsby 模式一起显示,因此这种行为符合预期。客户端查询是单独处理的 - 请参阅https://github.com/jlengstorf/gatsby-with-apollo以及中间相关的 You Tube 视频https://www.youtube.com/watch?v=wNUg1jpj9T0以获得良好的描述.


推荐阅读