Skip to content

[Gen2] Rest API setup will cause error "Subscribe only available for AWS AppSync endpoint" #7665

Open
@hangoocn

Description

@hangoocn

Describe the bug
The code below will cause "Subscribe only available for AWS AppSync endpoint" when calling "client.models.Todo.observeQuery().subscribe" in react code.

import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';

Amplify.configure(outputs);
const existingConfig = Amplify.getConfig();
Amplify.configure({
  ...existingConfig,
  API: {
    REST: outputs.custom.API,
  },
});

It can be fixed by adding line ...existingConfig.API :

import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';

Amplify.configure(outputs);
const existingConfig = Amplify.getConfig();
Amplify.configure({
  ...existingConfig,
  API: {
    ...existingConfig.API,
    REST: outputs.custom.API,
  },
});

Also warning message "warning "GraphQLAPI resolveConfig - The API configuration is missing"

To Reproduce
Steps to reproduce the behavior:

  1. Create an amplify gen2 react-vite app following the quickstart: https://docs.amplify.aws/react/start/quickstart/
  2. Add reset api follow this guide: https://docs.amplify.aws/react/build-a-backend/add-aws-services/rest-api/set-up-rest-api/#initialize-amplify-api
  3. Then we get error "client.models.Todo.observeQuery().subscribe" when calling "client.models.Todo.observeQuery().subscribe"

Expected behavior
No error

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions