aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

Im using AWS amplify (auth and api) on Nextjs. #3037

Closed anarerdene closed 4 years ago

anarerdene commented 5 years ago

AWS AppSync based on Apollo. So it means i don't need Apollo client on my Next'js project ?. I'm really confusing with Apollo or without Apollo. Right now im using like this image.

`import App, {Container} from 'next/app'; import React, {Component} from 'react'; import {ApolloProvider, compose} from 'react-apollo'; import Link from 'next/link'; import Head from 'next/head';

// AWS Appsync Config import AWSAppSyncClient from 'aws-appsync'; import {Rehydrated} from 'aws-appsync-react'; import Amplify, {Auth} from 'aws-amplify'; import config from '../src/aws-exports';

const client = new AWSAppSyncClient({ url: config.aws_appsync_graphqlEndpoint, region: config.aws_project_region, auth: { type: config.aws_appsync_authenticationType, jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken() } });

Auth.currentCredentials() .then(d => console.log('data: ', d)) .catch(e => console.log('error: ', e));

// App Layout class MyApp extends App { static async getInitialProps({Component, router, ctx}) { let pageProps = {};

if (Component.getInitialProps) {
  pageProps = await Component.getInitialProps(ctx);
}

return {pageProps};

}

render() { const {Component, pageProps} = this.props;

return (
  <Container>
    <Head>
      <meta charSet="utf-8" />
      <title>Amu Nutrition. Хүнсээр анагаах соёлыг дэлхий дахинд түгээнэ.</title>
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    </Head>

    <ApolloProvider client={client}>
      <Component {...pageProps} />
    </ApolloProvider>
  </Container>
);

} }

export default MyApp; `

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

ericclemmons commented 4 years ago

Keeping this open to track with #5435

github-actions[bot] commented 3 years ago

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 *-help channels or Discussions for those types of questions.