无法在Apollo GraphQL中的查询中使用@client@export变量

无法在Apollo GraphQL中的查询中使用@client@export变量,graphql,apollo,react-apollo,apollo-client,apollo-server,Graphql,Apollo,React Apollo,Apollo Client,Apollo Server,我只想使用@client(localcache)变量作为apollo服务器的查询参数。文档引用@export指令() 由于某种原因,我不能做像这样的事情 export const GET_COMPANY_DATA = gql` query GetCompanyData($id: ID!, $name: STRING!) { group @client @export(as: "name") getCompanyData(id: $id) { company {

我只想使用@client(localcache)变量作为apollo服务器的查询参数。文档引用@export指令()

由于某种原因,我不能做像这样的事情

export const GET_COMPANY_DATA = gql`
  query GetCompanyData($id: ID!, $name: STRING!) {
    group @client @export(as: "name")
    getCompanyData(id: $id) {
      company {
        groups(name: $name) {
          data
        }
      }
    }
  }
;
两个查询分别工作,例如:

{
  group @client
}
从本地缓存中返回应返回的字符串

export const GET_COMPANY_DATA = gql`
  query GetCompanyData($id: ID!, $name: STRING!) {
    getCompanyData(id: $id) {
      company {
        groups(name: $name) {
          data
        }
      }
    }
  }
;
返回正确的对象类型

在文档中,它们显示了这个示例,没有参考模式:

const query = gql`
  query currentAuthorPostCount($authorId: Int!) {
    currentAuthorId @client @export(as: "authorId")
    postCount(authorId: $authorId) @client
  }
`;

我做错了什么?我觉得我遗漏了一些基本概念…

我找到了它;设置apollo客户端时,即使您没有以下属性,也必须添加Resolver属性:

const client = new ApolloClient({
  cache,
  link: authLink.concat(httpLink),
  **resolvers: {}**
});