React Relay Uncaught Error:GraphQL验证错误``无法查询字段“clientList”on type“Query”。

时间:2017-03-01 12:45:20

标签: javascript graphql relayjs relay graphql-js

我已经为主页面做了一个查询并且它工作得很完美但是当我尝试对/ clients页面进行另一个中继查询时,继电器看不到我添加到服务器的新类型。这非常奇怪,因为当我运行update-schema时,schema.graphql上会出现类型,当我尝试使用graphiql查询它时,它也能正常工作。

我得到的错误:

  

未捕获错误:文件中的GraphQL验证错误Cannot query field "clientList" on type "Query". Did you mean "countryList"?   /home/robert/Sites/relay-test/src/queries/ClientQuery.js。尝试   如果最近有参数/字段/类型,则更新GraphQL架构   加入

ClientQuery.js

import Relay from 'react-relay';

export default {
    clientList: () => Relay.QL`query { clientList }`,
};

schema.graphql

# A list of clients
type ClientList implements NodeInterface {
  # The ID of an object
  id: ID!
  clientListId: Int

  # List of clients
  clients(after: String, first: Int, before: String, last: Int): LcoClientConnection
}

# A country
type Country implements NodeInterface {
  # The ID of an object
  id: ID!
  countryId: Int
  phonePrefix: String
  name: String
  timezone: String
}

# A connection to a list of items.
type CountryConnection {
  # Information to aid in pagination.
  pageInfo: PageInfo!

  # A list of edges.
  edges: [CountryEdge]
}

# An edge in a connection.
type CountryEdge {
  # The item at the end of the edge
  node: Country

  # A cursor for use in pagination
  cursor: String
}

# A list of countries
type CountryList implements NodeInterface {
  # The ID of an object
  id: ID!
  countryListId: Int

  # Countries list
  countries(after: String, first: Int, before: String, last: Int): CountryConnection
}

# Representation of date and time in "Y-m-d H:i:s" format
scalar DateTime

# A client
type LcoClient implements NodeInterface {
  # The ID of an object
  id: ID!
  name: String
  country: Country
  address: String
  description: String
}

# A connection to a list of items.
type LcoClientConnection {
  # Information to aid in pagination.
  pageInfo: PageInfo!

  # A list of edges.
  edges: [LcoClientEdge]
}

# An edge in a connection.
type LcoClientEdge {
  # The item at the end of the edge
  node: LcoClient

  # A cursor for use in pagination
  cursor: String
}

interface NodeInterface {
  # The ID of an object
  id: ID!
}

# Information about pagination in a connection.
type PageInfo {
  # When paginating forwards, are there more items?
  hasNextPage: Boolean!

  # When paginating backwards, are there more items?
  hasPreviousPage: Boolean!

  # When paginating backwards, the cursor to continue.
  startCursor: String

  # When paginating forwards, the cursor to continue.
  endCursor: String
}

type Query {
  # Fetches an object given its ID
  node(
    # The ID of an object
    id: ID!
  ): NodeInterface
  viewer: User
  countryList: CountryList
  clientList: ClientList
}

type User implements NodeInterface {
  # The ID of an object
  id: ID!
  username: String
  userId: Int
  lastLoginDateTime: DateTime
}

查询“viewer”和“countryList”类型有效。

我在SO上看过类似的线程,但他们没有解决问题。

我错过了什么?

0 个答案:

没有答案
相关问题