简体   繁体   English

Apollo GraphQL 查询中缺少字段

[英]Missing field in Apollo GraphQL Query

I'm using react with Apollo and a F# backend.我正在使用与 Apollo 和 F# 后端的反应。

When i make a query i get an error similar to this but i'm not sure why as it seems like stories is present in the response.当我进行查询时,我收到与此类似的错误,但我不确定为什么,因为响应中似乎存在故事。

Missing field stories in "{\"stories\":[{\"name\":\"Story1\",\"__typename\":\"Story\"},{\"name\":\"Story2\",\"__typename\":\

My code for making the query is:我进行查询的代码是:

const client = new ApolloClient({
    uri: '/graphql',
});

client
    .query({
        query: gql`
      query testStoryQuery
    {

        stories
        {
            name

        }

    }
    `
    })
    .then(result => console.log(result));

Finally the raw response returned by the server is:最后服务器返回的原始响应是:


{"data":"{\"stories\":[{\"name\":\"Story1\",\"__typename\":\"Story\"},{\"name\":\"Story2\",\"__typename\":\"Story\"},{\"name\":\"Story3\",\"__typename\":\"Story\"}]}"}

The only thing I've tried so far is jsonifying the response (ie the ") around fields, but it doesn't seem to find the field either way.到目前为止,我唯一尝试过的方法是对字段周围的响应(即“)进行 jsonify 化,但似乎无论如何都找不到该字段。

Update (extra info)更新(额外信息)

The full stack trace完整的堆栈跟踪

浏览器错误的堆栈跟踪

Any help would be appreciated, i'll continue working on it in the meantime.任何帮助将不胜感激,同时我会继续努力。

Thank you :)谢谢 :)

Bad response format:错误的响应格式:

{"data": ____"____ {\\"stories\\":[{\\"name\\":\\"Story1\\",\\"__typename\\":\\"Story\\"},{\\"name\\":\\"Story2\\",\\"__typename\\":\\"Story\\"},{\\"name\\":\\"Story3\\",\\"__typename\\":\\"Story\\"}]} ____"____ } {"data": ____"____ {\\"stories\\":[{\\"name\\":\\"Story1\\",\\"__typename\\":\\"Story\\"},{\\"name\\":\\ "Story2\\",\\"__typename\\":\\"Story\\"},{\\"name\\":\\"Story3\\",\\"__typename\\":\\"Story\\"}]} ____"____ }

This way data is a string, not object.这样 data 是一个字符串,而不是对象。

Also bad names \\r\\n\\t\\t\\t\\t__typename in a stack trace.堆栈跟踪中还有坏名\\r\\n\\t\\t\\t\\t__typename

For more details run some working example (any apollo client project) and compare arguments passed to writeToStore.ts methods using browser debugger breakpoints.有关更多详细信息,请运行一些工作示例(任何 apollo 客户端项目)并使用浏览器调试器断点比较传递给writeToStore.ts方法的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM