2

我是graphql和relay的新手,但我做的一切都很好。我尝试new GraphQLList(Property)使用 graphql 查询来获取props.properties我的站点属性列表(

{
    __dataID__: "client:11752076762",
    properties: {
        __dataID__: "client:11752076762",
        __status__: 4
    },
    __status__: 4
}

而不是获取的属性。

我很困惑,有什么问题?:(

4

2 回答 2

1

首先尝试在 graphiql 中运行查询。

...
  .use('/graphql', graphqlHTTP({ schema, pretty: true, graphiql: true }))

然后尝试确认您在该查询中得到了您要查找的内容

于 2016-03-27T04:44:17.970 回答
0

这可能与您的方式有关:

  • 定义您的 GraphQL 架构(如果可能,请提供架构)
  • 在 Relay.Container 中声明 GraphQL 数据片段要求(您需要明确声明所需的所有字段)
  • 在 Relay.Route 中声明 GraphQL 路由

Relay.Container 示例:

Relay.createContainer(App, {
  fragments: {
    properties:  () => Relay.QL`
      fragment on Properties {

        <IMPORTANT: fields that you want to be in props.properties should be here> 

      }
    `
    ...
  }
}

Relay.Route 示例:

Relay.Route {
  static queries = {
    properties: () => Relay.QL`
      query {
        properties
      }
    `,
  }
}
于 2016-03-29T02:23:03.120 回答