Giter Site home page Giter Site logo

Comments (5)

calpa avatar calpa commented on June 11, 2024

GraphQL 是作为前端获取数据的查询方法,发送请求还是用 axios 吧。。。

from gatsby-starter-calpa-blog.

zwl1619 avatar zwl1619 commented on June 11, 2024

@calpa
前端使用了GraphQL ,那服务端也必须要使用GraphQL来和前端GraphQL交互吧?
GraphQL在GatsbyJS中是必须要使用的吗?如果再使用axios,restful和GraphQL就同时存在了。

from gatsby-starter-calpa-blog.

calpa avatar calpa commented on June 11, 2024

如果你的后端是使用 GraphQL 的话,那么你可以直接使用 gatsby-source-graphql 来调用后端提供的 GraphQL 接口。这样就无需 axios 和 restful。

比如说你需要调 Github 接口,那么你直接这样写查询语句就可以了:

{
  github {
    viewer {
      email
    }
  }
}

详见:https://www.gatsbyjs.org/packages/gatsby-source-graphql/

from gatsby-starter-calpa-blog.

zwl1619 avatar zwl1619 commented on June 11, 2024

@calpa
有点不太明白,如果后端没有使用GraphQL,那GraphQL在GatsbyJS中怎么能从后端获取数据?

from gatsby-starter-calpa-blog.

calpa avatar calpa commented on June 11, 2024

from gatsby-starter-calpa-blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.