Tag: apollo client

使用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 […]