Tag: graphql

使用Rails,Graphql,Apollo客户端的无效令牌

我试图让一个基本的Rails,Graphql,Apollo-Client设置工作,但在rails侧遇到422个错误’无效的auth令牌’。 我使用apollo看起来不对吗? 它是一个带有graphql gem和apollo客户端的Rails 5应用程序。 const csrfToken = document.getElementsByName(‘csrf-token’)[0].content const client = new ApolloClient({ networkInterface: createNetworkInterface({ uri: ‘/graphql’, credentials: ‘same-origin’, headers: { ‘X-CSRF-Token’: csrfToken } }), }); client.query({ query: gql` query Camillo2 { user { id email created_at } } `, }) .then(data => console.log(data)) .catch(error => console.error(error)); Rails日志: Started POST “/graphql” for ::1 at […]

如何在Graphql上定义动态变量?

所以,我正在使用ruby on rails。 这是我的代码: require ‘graphql/client’ require ‘graphql/client/http’ HTTP = GraphQL::Client::HTTP.new(“Graph-API-Web-Site”) Schema = GraphQL::Client.load_schema(HTTP) Client = GraphQL::Client.new(schema: Schema,execute: HTTP) Query = Client.parse <<-'GRAPHQL' query($message: String = "Hello") { stickers(query: $message, first: 21, after: "") { edges { node { fileUrl(fullWatermarked: true) } } } } GRAPHQL result = Client.query Query puts result.data.inspect 如何为贴纸{query: …..}区域赋予特定价值? 我想用程序运行更改消息的值。 […]