awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
921 stars 266 forks source link

Subscribe only available for AWS AppSync endpoint #717

Closed phucnguyencong closed 1 year ago

phucnguyencong commented 2 years ago

I get issues when using @apollo/client: 3.5.10, aws-appsync-auth-link: 3.0.7, aws-appsync-subscription-link: 3.0.10. There is my config

import { ApolloClient, ApolloLink, createHttpLink, InMemoryCache } from '@apollo/client';
import { createAuthLink } from 'aws-appsync-auth-link';
import { createSubscriptionHandshakeLink } from 'aws-appsync-subscription-link';
// Config
import { AWS_APPSYNC } from '../config';

const { graphqlEndpoint, region, apiKey } = AWS_APPSYNC;
const auth = {
  type: AWS_APPSYNC.authenticationType,
  apiKey: apiKey,
};

const httpLink = createHttpLink({ uri: graphqlEndpoint });
const link = ApolloLink.from([
  // @ts-ignore
  createAuthLink({ graphqlEndpoint, region, auth }),
  // @ts-ignore
  createSubscriptionHandshakeLink({ graphqlEndpoint, region, auth }, httpLink),
]);

export const client = new ApolloClient({
  link,
  cache: new InMemoryCache(),
});

and I am using

  const {
    data: subscription_message_data,
    loading: subscription_message_loading,
    error: subscription_message_error
  } = useSubscription(
    SUBSCRIPTION_NEW_MESSAGE, {
      variables: { conversationId: conversationId }
    });

But I got an error form useSubscription is: "Subscribe only available for AWS AppSync endpoint"

Does anyone have experience with this issue?

iartemiev commented 1 year ago

Hi, are you still experiencing this issue? If so, have you tried updating to the latest version of the libary - 4.1.9?

phucnguyencong commented 1 year ago

Hi, are you still experiencing this issue? If so, have you tried updating to the latest version of the libary - 4.1.9?

The main issue from my configuration and I had fixed without upgrade version

phucnguyencong commented 1 year ago

I was resolve this issue

Ishara-Mee commented 5 months ago

Hi @phucnguyencong , Can you please explain the configuration issue you had ? Im having the same problem