Android emulator Appsync订阅不起作用,但查询和转换工作正常

Android emulator Appsync订阅不起作用,但查询和转换工作正常,android-emulator,react-native-android,subscription,aws-appsync,graphql-tag,Android Emulator,React Native Android,Subscription,Aws Appsync,Graphql Tag,我正在构建一个简单的React原生应用程序。测试AppSync API。我能做查询,突变;但订阅似乎不起作用。我正在Android仿真器上试用 下面是我如何构建我的客户机并创建订阅 const client = new AWSAppSyncClient({ url: awsconfig.aws_appsync_graphqlEndpoint, region: awsconfig.aws_appsync_region, auth: { t

我正在构建一个简单的React原生应用程序。测试AppSync API。我能做查询,突变;但订阅似乎不起作用。我正在Android仿真器上试用

下面是我如何构建我的客户机并创建订阅

    const client = new AWSAppSyncClient({
      url: awsconfig.aws_appsync_graphqlEndpoint,
      region: awsconfig.aws_appsync_region,
      auth: {
        type: AUTH_TYPE.API_KEY, // or type: awsconfig.aws_appsync_authenticationType,
        apiKey: awsconfig.aws_appsync_apiKey,
      }
    });

    subscription = client.subscribe({ query: gql(onCreateBook) }).subscribe({
        next: data => {
          console.log("got a book--->");
        },
        error: error => {
          console.warn("errror getting book");
        }
      });

这是我的模式(相关部分)和订阅gql(由codeGen自动生成)

模式

type Book {
    title: String!
    description: String
}

type Mutation {
    createBook(input: CreateBookInput!): Book
    updateBook(input: UpdateBookInput!): Book
    deleteBook(input: DeleteBookInput!): Book
}

type Query {
    getBook(title: String!): Book
    listBooks(filter: TableBookFilterInput, limit: Int, nextToken: String): BookConnection
}

type Subscription {
    onCreateBook(title: String, description: String): Book
        @aws_subscribe(mutations: ["createBook"])
    onUpdateBook(title: String, description: String): Book
        @aws_subscribe(mutations: ["updateBook"])
    onDeleteBook(title: String, description: String): Book
        @aws_subscribe(mutations: ["deleteBook"])
}
订阅gql

// eslint-disable
// this is an auto generated file. This will be overwritten

export const onCreateBook = `subscription OnCreateBook($title: String, $description: String) {
  onCreateBook(title: $title, description: $description) {
    title
    description
  }
}
`;
export const onUpdateBook = `subscription OnUpdateBook($title: String, $description: String) {
  onUpdateBook(title: $title, description: $description) {
    title
    description
  }
}
`;
export const onDeleteBook = `subscription OnDeleteBook($title: String, $description: String) {
  onDeleteBook(title: $title, description: $description) {
    title
    description
  }
}
`;

注意:我已经验证了订阅在AWS控制台中触发变异时工作正常,但我在ReactNative应用程序中看不到任何错误