How to use the aws-appsync/lib/link/auth-link.AUTH_TYPE.AMAZON_COGNITO_USER_POOLS function in aws-appsync

To help you get started, we’ve selected a few aws-appsync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ConduitVC / appsync-serverless-emulator-example / src / App.jsx View on Github external
import { withAuthenticator } from 'aws-amplify-react';
import AWSAppSyncClient from 'aws-appsync';
import { Rehydrated } from 'aws-appsync-react';
import { AUTH_TYPE } from 'aws-appsync/lib/link/auth-link';
import { Component } from 'react';
import { ApolloProvider } from 'react-apollo';
import Roundtrip from './Roundtrip';

const client = new AWSAppSyncClient({
  url: 'http://localhost:62222/graphql',
  // url:
    // 'https://sgdhr5dvovavfa6frgekxw3fi4.appsync-api.us-east-1.amazonaws.com/graphql',
  region: 'us-east-1',
  disableOffline: true,
  auth: {
    type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
    jwtToken: async () =>
      (await Auth.currentSession()).getIdToken().getJwtToken(),
  },
});

console.log('>>> START');
Amplify.configure({
  Auth: {
    userPoolId: 'us-east-1_27WcML9k8',
    userPoolWebClientId: 'q4ppu404sdiqlcjg21756hvap',
    region: 'us-east-1',
  },
});

class App extends Component {
  render() {
github serverless / serverless-graphql / app-client / appsync-client / src / App.js View on Github external
import Search from './routes/Search';
import { Footer } from './components/helpers';

Amplify.configure({
  Auth: {
    region: process.env.REACT_APP_AWS_AUTH_REGION, // REQUIRED - Amazon Cognito Region
    userPoolId: process.env.REACT_APP_USER_POOL_ID, // OPTIONAL - Amazon Cognito User Pool ID
    userPoolWebClientId: process.env.REACT_APP_CLIENT_APP_ID, // User Pool App Client ID
  },
});

const client = new AWSAppSyncClient({
  url: process.env.REACT_APP_GRAPHQL_ENDPOINT,
  region: process.env.REACT_APP_AWS_CLIENT_REGION,
  auth: {
    type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
    jwtToken: async () =>
      (await Auth.currentSession()).getIdToken().getJwtToken(),
  },
});

const WithProvider = () => (
  
    
      
        
        
        
        <footer>
          Home
          <span> | </span>
          Search</footer>
github aws-samples / aws-mobile-appsync-chat-starter-angular / src / app / chat-app / appsync.service.ts View on Github external
constructor() {
     const client = new AWSAppSyncClient({
       url: aws_exports.aws_appsync_graphqlEndpoint,
       region: aws_exports.aws_project_region,
       auth: {
         type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
         jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken()
       }
     });
     // this.hc = client.hydrated;
     this._hc = client;
   }
   hc() {
github pjay79 / MoviesApp / App.js View on Github external
import Amplify, { Auth } from 'aws-amplify';
import AWSAppSyncClient from 'aws-appsync';
import { Rehydrated } from 'aws-appsync-react';
import { AUTH_TYPE } from 'aws-appsync/lib/link/auth-link';
import { ApolloProvider } from 'react-apollo';
import awsConfig from './app/aws-exports';
import appSyncConfig from './app/aws-appsync';
import MainNavigator from './app/routes/MainNavigator';

Amplify.configure(awsConfig);

const appSyncClient = new AWSAppSyncClient({
  url: appSyncConfig.graphqlEndpoint,
  region: appSyncConfig.region,
  auth: {
    type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
    jwtToken: async () =&gt; (await Auth.currentSession()).getIdToken().getJwtToken(),
  },
});

const App = () =&gt; (
  
    
      
    
  
);

export default App;