Apollo客户自省查询

时间:2018-09-29 20:18:29

标签: graphql apollo-client apollo-boost

在操场上工作...

我正在尝试查询以下枚举值:

apache2handler

当我在操场上测试查询时,它可以工作。我收到了query { __type(name:"ActivityType") { enumValues { name } } } 的枚举值的列表:

不能与Apollo-Client合作...

当我在客户端上运行以下代码时,我收到了第一个查询的预期结果,但没有收到第二个查询的预期结果:

ActivityType

结果

import ApolloClient, { gql } from 'apollo-boost'

const FIRST_QUERY = gql`
  query successfulQuery {
    totalActivities
  }
`

const SECOND_QUERY = gql`
  query unsuccessfulQuery {
    __type(name:"ActivityType") {
      enumValues {
        name
      }
    }
  }
`

const client = new ApolloClient({ uri: 'http://localhost:4000' })

//
// First Query returns data
//

client.query({ query: FIRST_QUERY })
  .then(console.log)
  .catch(console.error)

//
// Second Query does not return data
//

client.query({ query: SECOND_QUERY })
  .then(console.log)
  .catch(console.error)  

您是否需要与客户端实施一些特殊功能以允许进行内省性查询?

0 个答案:

没有答案
相关问题