-
Notifications
You must be signed in to change notification settings - Fork 267
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
Updated link packages to use Apollo 3 #561
Conversation
This PR resolves a dependency on |
Not sure how the @joebernard You can use the versions I published to NPM if you'd like, and then force the latest version of Apollo via resolutions in package.json:
(note: I don't actually know if it'll like that, I don't use the links anymore, I'm on a dif backend since I opened the PR. Worth trying though) |
Thanks @lukeramsden that is very helpful. @manueliglesias @elorzafe Do you have any input on how we might get this update rolled out? I understand that Apollo 3 is still in beta but perhaps we could get an |
apollo client 3.0 has reached stable version |
Any news regarding this issue? |
This would be great now that Apollo 3 has been released! I'm currently staying on Apollo 2 to avoid having to import both versions and dealing with type inconsistencies. |
Any update on this? |
I'm sad this hasn't been merged yet :( |
Are you surprised? |
lol @mikedizon I am a little bit ye. Its a pretty big package and its awslabs.... I assumed they were on salary, but maybe I am mistaken? |
@lukeramsden Can you look to resolve the conflicts ? |
It would also make sense to update the deps for apollo/client as its out of beta now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good to add support to aws-appsync-auth-link
and aws-appsync-subscription-link
on Apollo 3.0 (I tested all different authorization modes) however it will be an issue when we try to publish because aws-appsync
will have to be updated to use the new links that will work with apollo 3.0.
The options are:
- Migrate aws-appsync to be compatible with apollo 3.0 which can take a long time
- Only publish auth-link and subscription-link and not publish
aws-appsync
andaws-appsync-react
that will require to update monorepopackage.json
file and setworkspaces
value to"workspaces": [ "packages/aws-appsync-subscription-link", "packages/aws-appsync-auth-link"]
that will removeaws-appsync
andaws-appsync-react
from monorepo release process.
@manueliglesias @undefobj @sammartinez what do you think?
@elorzafe @manueliglesias @sammartinez my vote is for option 2 as this gets the links in hands of customers. |
Im in agreement, lets look to do this today then @manueliglesias and @undefobj since @elorzafe is out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes 👍
Do you have plans to release updated |
Hi, The link packages are published in npm under the
tested with: import { ApolloClient, from, gql, HttpLink, InMemoryCache, split } from "@apollo/client";
import { AUTH_TYPE, createAuthLink } from "aws-appsync-auth-link";
import { createSubscriptionHandshakeLink } from "aws-appsync-subscription-link";
import React, { useEffect } from "react";
import "./App.css";
import awsConfig from "./aws-exports";
import logo from "./logo.svg";
const httpLink = new HttpLink({
uri: awsConfig.aws_appsync_graphqlEndpoint,
});
const client = new ApolloClient({
cache: new InMemoryCache(),
link: from([
createAuthLink({
url: awsConfig.aws_appsync_graphqlEndpoint,
auth: {
type: AUTH_TYPE.API_KEY,
apiKey: awsConfig.aws_appsync_apiKey,
},
region: awsConfig.aws_appsync_region,
}),
split(op => {
const {operation} = op.query.definitions[0] as any;
if(operation === 'subscription') {
return false;
}
return true;
}, httpLink, createSubscriptionHandshakeLink(
{
auth: {
type: AUTH_TYPE.API_KEY,
apiKey: awsConfig.aws_appsync_apiKey,
},
region: awsConfig.aws_appsync_region,
url: awsConfig.aws_appsync_graphqlEndpoint,
},
httpLink
))
]),
});
function App() {
useEffect(() => {
const sub = client.subscribe({
query: gql`subscription S {
onCreateNote{
id
}
}`
}).subscribe(console.warn);
return () => sub.unsubscribe();
}, []);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
<button onClick={testClient}>TEST</button>
</header>
</div>
);
async function testClient() {
const result = await client.query({
query: gql`query Q {
syncNotes {
items {
id
}
}
}`
});
console.log({result});
}
}
export default App; aws-exports.js (generated by Amplify CLI) // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-1",
"aws_appsync_graphqlEndpoint": "https://xxxxxxxxxxxxxxxxxxxx.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "da2-xxxxxxxxxxxxxxxxxx"
}; |
Looks like aws-appsync-subscription-link still depends on the old version of aws-appsync-auth-link: https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/master/packages/aws-appsync-subscription-link/package.json#L23 Should that be updated? It ends up pulling Apollo 2 into the dependency graph. |
Good catch @colinwilliams , I'll look into it |
@colinwilliams New versions to address this are in npm:
Apollo 2 no longer shows in the dependency graph:
|
@manueliglesias thanks for this example, it works perfectly. Does this allow for offline stuffs as well, or no? |
Anything change here? I'm using the example and I'm getting this on subscriptions: https://www.dropbox.com/s/splibjoysggqe3t/Screen%20Shot%202021-04-08%20at%203.33.04%20PM.png?dl=0 Connection failed: {"errors":[{"errorType":"BadRequestException","message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'POST\n/graphql\n\naccept:/\ncontent-type:application/json; charset=UTF-8\nhost:72wbtuzs6ff2ljhuvlun4rxeqe.appsync-api.us-east-1.amazonaws.com\nx-amz-date:20210408T193145Z\nx-amz-security-token:IQoJb3JpZ2luX2VjEAwaCXVzLWVhc3QtMSJGMEQCIHcyJHWAmzuCyLl8GRapSnUlBw/QSXTaVZC4JwbFRbOOAiByZLIQRuoj1usmqEZkWciLPl5R3kdVxG0TYa8xCmBcrSqRBghlEAEaDDEwMjA0MTEyMDUyMCIMryikg1ixp7tsaRPhKu4FoHORnDRYU7omcNmGUp1ssaiTSnGhJ+esxxL/A/AgfnfsvODTnubLS/wiQIfXFIQQodagwUOa8TQsL5Wg2x6xjeO7Fk25YJKJM2fk/JyMW44Z/x+zRbtwVDOFneFlr+IJ/7uS5Q6UMDMvnSh805an3vKBMqQSu8Xd+U5PhxKePyHS7xiy5uSqD/gRXBhuSLPXRQJ9/ep24L5eeqCnmT1oqJKUXGC4DZaesKF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TFId9pY1i4G/EexdApQcX5mb5HnSUIifLo7f91+3b28ur09aZ8LqVhRMEAw+6bAy7g6KrSQapmID\n\naccept;content-type;host;x-amz-date;x-amz-security-token\n16981f65eb3d008e35a503f8f3ae4ed44557684fa879763eb19f274c444c5ddb'\n\nThe String-to-Sign should have been\n'AWS4-HMAC-SHA256\n20210408T193145Z\n20210408/us-east-1/appsync/aws4_request\n2296a4d8575aa53a9acc41ce83e980ac631582ac96cfcd2cc63bc4f6ccb51729'\n"}]} |
Issue #: #525
Description of changes: Updated imports to use the new scoped
@apollo/client
imports. Also bumped version number of both packages to 3.0.0 due to this most likely being a breaking change for consumers (although all tests pass on my machine!)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.