简体   繁体   English

GraphQL 类型的突变变量不知何故永远不会改变

[英]GraphQL type of mutation variable somehow never changes

this behaviour does not make sense to me anymore.这种行为对我来说不再有意义。

My mutation:我的突变:

export const DEVICE_CREATE_INPUT = gql`
    mutation CreateDevice(
        $attributeList: String
      ) {
        createDevice(
          input: {
            attributeList: $attributeList
          }
        ) {
          device {
            id
            _id
          }
        }
      }
`;

My typescript code:我的 typescript 代码:

private createDeviceRequest(
    attributeList: string,
  ) {
    return this.apollo.mutate({
      mutation: DEVICE_CREATE_INPUT,
      variables: {
        attributeList
      }
    });
  }

When I try to send the mutation (attributeList = "") it gives me following error message:当我尝试发送突变(attributeList =“”)时,它给了我以下错误消息:

zone-evergreen.js:659 Unhandled Promise rejection: Variable "$attributeList" of type "String" used in position expecting type "Iterable!". ; Zone: <root> ; Task: Promise.then ; Value: Error: Variable "$attributeList" of type "String" used in position expecting type "Iterable!".
    at new ApolloError (index.js:26)
    at Object.next (QueryManager.js:88)
    at notifySubscription (Observable.js:135)
    at onNotify (Observable.js:179)
    at SubscriptionObserver.next (Observable.js:235)
    at iteration.js:4
    at Array.forEach (<anonymous>)
    at iterateObserversSafely (iteration.js:4)
    at Object.next (Concast.js:25)
    at notifySubscription (Observable.js:135) Error: Variable "$attributeList" of type "String" used in position expecting type "Iterable!".
    at new ApolloError (http://localhost:8100/vendor.js:62615:28)
    at Object.next (http://localhost:8100/vendor.js:152614:53)
    at notifySubscription (http://localhost:8100/vendor.js:136374:18)
    at onNotify (http://localhost:8100/vendor.js:136418:3)
    at SubscriptionObserver.next (http://localhost:8100/vendor.js:136474:7)
    at http://localhost:8100/vendor.js:1059:68
    at Array.forEach (<anonymous>)
    at iterateObserversSafely (http://localhost:8100/vendor.js:1059:25)
    at Object.next (http://localhost:8100/vendor.js:70868:97)
    at notifySubscription (http://localhost:8100/vendor.js:136374:18)

I did use the type 'Iterable,' at some point.在某些时候,我确实使用了“Iterable”类型。 but I wanted to switch to string and changed it everywhere in the frontend where I could find it.但我想切换到字符串并在前端的任何地方都可以找到它。 If I do a full search now in my frontend code for 'Iterable' I find nothing anymore?如果我现在在我的前端代码中对“Iterable”进行全面搜索,我什么也找不到了? Is this a cache problem?这是缓存问题吗?

This error occurred because expected input type for createDevice mutation doesn't match the provided type.发生此错误是因为 createDevice 突变的预期输入类型与提供的类型不匹配。 If you want to use String instead of Iterable you should change typedef of attributeList at your backend from Iterable to String.如果要使用 String 而不是 Iterable,则应将后端的 attributeList 的 typedef 从 Iterable 更改为 String。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM