Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(subscription): update request return type correctly match apollo-link #727

Closed
wants to merge 2 commits into from

Conversation

dpilch
Copy link

@dpilch dpilch commented Jul 7, 2022

Description of changes:
Continuing change from #566. This change was originally created by a contributor but it appears to have been abandoned. See #566 for full description.

See v2 change: #728

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Mark Wolfe and others added 2 commits July 7, 2022 09:59
…link

Current type which doesn't compile.

```
    request(operation: Operation): Observable<unknown>;
```

New type after change which compiles

```
    request(operation: Operation): Observable<FetchResult> | null;
```
@dpilch
Copy link
Author

dpilch commented Jul 12, 2022

Canceling this change. Please use ApolloLink exported from @apollo/client and there shouldn't be an issue.

import React from "react";
import { registerRootComponent } from "expo";
import Amplify from "aws-amplify";
import AppSyncConfig from "./src/aws-exports";
import { createAuthLink } from "aws-appsync-auth-link";
import { createSubscriptionHandshakeLink } from "aws-appsync-subscription-link";
import {
  ApolloLink,
  ApolloClient,
  ApolloProvider,
  InMemoryCache,
} from "@apollo/client";
import App from "./App";

Amplify.configure(AppSyncConfig);

const url = AppSyncConfig.aws_appsync_graphqlEndpoint;
const region = AppSyncConfig.aws_appsync_region;
const auth = {
  type: AppSyncConfig.aws_appsync_authenticationType,
  apiKey: AppSyncConfig.aws_appsync_apiKey,
};

const link = ApolloLink.from([
  createAuthLink({ url, region, auth }),
  createSubscriptionHandshakeLink({ url, region, auth }),
]);

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

const WithProvider = () => (
  <ApolloProvider client={client}>
    <App />
  </ApolloProvider>
);

export default registerRootComponent(WithProvider);

@dpilch dpilch closed this Jul 12, 2022
@dguisinger
Copy link
Contributor

Canceling this change. Please use ApolloLink exported from @apollo/client and there shouldn't be an issue.

import React from "react";
import { registerRootComponent } from "expo";
import Amplify from "aws-amplify";
import AppSyncConfig from "./src/aws-exports";
import { createAuthLink } from "aws-appsync-auth-link";
import { createSubscriptionHandshakeLink } from "aws-appsync-subscription-link";
import {
  ApolloLink,
  ApolloClient,
  ApolloProvider,
  InMemoryCache,
} from "@apollo/client";
import App from "./App";

export default registerRootComponent(WithProvider);

@dpilch This doesn't fix problems with Angular Apollo. @apollo/client has a dependency on React whereas @apollo/client/core does not. There is a whole thread about @apollo/client vs @apollo/client/core over at the Apollo repo: apollographql/apollo-client#7318

The original fix in #566 of changing it to Observable on the return type gets that line to build.

I'm also adding my name to others on #713 that ZenObservable is also failing to build in Angular projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants