Types GraphQL类型的变异变量以某种方式永远不会改变

Types GraphQL类型的变异变量以某种方式永远不会改变,types,graphql,apollo,scalar,Types,Graphql,Apollo,Scalar,这种行为对我来说再也没有意义了 我的变异: export const DEVICE_CREATE_INPUT = gql` mutation CreateDevice( $attributeList: String ) { createDevice( input: { attributeList: $attributeList } ) { dev

这种行为对我来说再也没有意义了

我的变异:

export const DEVICE_CREATE_INPUT = gql`
    mutation CreateDevice(
        $attributeList: String
      ) {
        createDevice(
          input: {
            attributeList: $attributeList
          }
        ) {
          device {
            id
            _id
          }
        }
      }
`;
我的打字脚本代码:

private createDeviceRequest(
    attributeList: string,
  ) {
    return this.apollo.mutate({
      mutation: DEVICE_CREATE_INPUT,
      variables: {
        attributeList
      }
    });
  }
当我尝试发送变异(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)
zone evergreen.js:659未处理的承诺拒绝:在预期类型为“Iterable!”的位置中使用了类型为“String”的变量“$attributeList”;区域:;任务:承诺;值:错误:在预期类型为“Iterable!”的位置中使用了类型为“String”的变量“$attributeList!”。
在新的时间点出错(index.js:26)
在Object.next(QueryManager.js:88)
在订阅时(Observable.js:135)
在onNotify(可观察到,js:179)
在SubscriptionObserver.next(Observable.js:235)
在iteration.js:4
在Array.forEach()处
在iterateObserversSafely(iteration.js:4)
在Object.next(Concast.js:25)
在notifySubscription(Observable.js:135)处,错误:在预期类型为“Iterable!”的位置中使用了类型为“String”的变量“$attributeList”。
新阿波罗错误(http://localhost:8100/vendor.js:62615:28)
在Object.next(http://localhost:8100/vendor.js:152614:53)
订阅时(http://localhost:8100/vendor.js:136374:18)
立即通知(http://localhost:8100/vendor.js:136418:3)
在SubscriptionObserver.next(http://localhost:8100/vendor.js:136474:7)
在http://localhost:8100/vendor.js:1059:68
在Array.forEach()处
在IterateObserversSafey(http://localhost:8100/vendor.js:1059:25)
在Object.next(http://localhost:8100/vendor.js:70868:97)
订阅时(http://localhost:8100/vendor.js:136374:18)

我确实使用了“Iterable”类型在某个时候,我想切换到字符串,并在前端任何我能找到它的地方更改它。如果我现在在前端代码中对“Iterable”进行完整搜索,我再也找不到任何东西了。这是缓存问题吗?

发生此错误是因为createDevice的预期输入类型与提供的类型不匹配。如果您想使用String而不是Iterable,您应该将后端attributeList的typedef从Iterable更改为String