【问题标题】:Trying out gatsby-theme-apollo - server not visible尝试 gatsby-theme-apollo - 服务器不可见
【发布时间】:2020-05-25 02:22:44
【问题描述】:

入门有问题 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 是否已启动 终端:盖茨比开发 浏览器:导航到 localhost:8000/___graphql

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

【问题讨论】:

    标签: gatsby react-apollo


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-04-01
      • 2020-08-10
      • 2020-01-04
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      • 2018-01-25
      • 2020-07-25
      • 2021-07-27
      相关资源
      最近更新 更多