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
Is it possible to use aws-amplify for GraphQL queries? #434
Comments
I'm using Apollo 2 with setContext link like this:
also, don't forget to put this somewhere in a top level file like
with regard to API gateway, you need to create a user pool and set the authorization to use that pool in the API gateway settings:
I did this a while ago, but if I remember correctly I also had to enable CORS and redeploy the resource. I'm using lambda and lambda proxy and this is what I have in my handler:
note that the userId is on I can't remember the details, but as you are testing keep in mind that for AWS you need to set up IAM roles to allow some services to work together. hope that helps EDIT: updated handler to include |
@mlabieniec Thank you! It is helpful for me, but I use IAM authorizer (NOT user pool authorizer like in your code). And the problem is that I can't just add authorizer header, because for IAM authorizer it is required to sign the request. I could sign the request using this code:
So, I need to get the request object. And I don't know how to get request object in Apollo |
AWS AppSync is a managed GraphQL service that you might find useful as an alternative of API Gateway + Lambda + apollo-server. I also mention AWS AppSync because it has a JavaScript client/sdk that can handle IAM Auth with sigv4 signing You can probably take pieces from there and adapt as needed, e.g.: Using the apollo client, you could add the auth-link from aws-appsync to the client link chain You might need to customize the auth-link.js a little I haven't tried this, but let me know how it goes! |
Closing. |
@manueliglesias @powerful23
|
@mixja I've tried this. My question is specifically for using amplify w/ appSync. AppSync seems to over write the headers. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
I need to send GraphQL queries to AWS API Gateway (IAM authorizer). I could use a GraphQL client library (for example Apollo) but I have a problem with signing the request. I could use aws-amplify signer.js but I can't get any request object from Apollo library. Are there some examples of how to use aws-amplify with GraphQL?
The text was updated successfully, but these errors were encountered: