GraphQL问题/接口

时间:2017-06-23 02:00:42

标签: javascript graphql graphql-js

问题

我做错了什么? GitHub有类似的东西,它可以工作。

#EDIT

使用 graphql-tools 一切正常。但是,如何在没有其他依赖性的情况下使其工作?

查询

query Help {
  node(id: 1) {
    id
    ... on Client {
      id
      firstName
      lastName
    }
  }
}

来自服务器的响应

Generated Schema无法使用Interface或Union类型执行。

架构+解析器

const schema = buildSchema(`
  type Query {
    node(id: Int): Node
  }

  interface Node {
    id: Int!
  }

  type Client implements Node {
    id: Int!
    firstName: String!
    lastName: String!
  }
`)

const root = {
  node: () => {
    // Experiment
    return {
      id: 1,
      firstName: 'A',
      lastName: 'B'
    }
  }
}

1 个答案:

答案 0 :(得分:0)

编辑:我搞砸了,看起来这可能是阿波罗的一个问题https://github.com/apollographql/apollo-client/issues/1741