Skip to content

Commit

Permalink
reinitialize amplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephenoch committed Oct 24, 2022
1 parent 0d113df commit 3301ffe
Show file tree
Hide file tree
Showing 16 changed files with 484 additions and 516 deletions.
3 changes: 3 additions & 0 deletions .graphqlconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ projects:
codeGenTarget: javascript
generatedFileName: ''
docsFilePath: src/graphql
extensions:
amplify:
version: 3
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.exclude": {
"amplify/.config": true,
"amplify/**/*-parameters.json": true,
"amplify/**/amplify.state": true,
"amplify/**/transform.conf.json": true,
"amplify/#current-cloud-backend": true,
"amplify/backend/amplify-meta.json": true,
"amplify/backend/awscloudformation": true
}
}
19 changes: 18 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import { StyleSheet, Text, View } from 'react-native';
import Navigator from './src/navigation';
import { Amplify} from 'aws-amplify';
import { Amplify, API, Auth, graphqlOperation} from 'aws-amplify';
import awsmobile from "./src/aws-exports"
import { withAuthenticator } from 'aws-amplify-react-native/dist/Auth';
import { useEffect } from 'react';
import { getUser } from './src/graphql/queries';

Amplify.configure({...awsmobile, Analytics:{disabled: true}})

const App = () => {
const handleAuth = async () =>{
try{
const currentUser = await Auth.currentAuthenticatedUser({bypassCache: true});
const user = await API.graphql(graphqlOperation(getUser, {
id: currentUser?.attributes?.sub
}))
console.log(user)
}
catch(err){
console.error(err)
}
}
useEffect(()=>{
handleAuth()
},[])
return (
<View style={styles.container}>
<Navigator/>
Expand Down
14 changes: 3 additions & 11 deletions amplify/backend/api/chatupmobile/cli-inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
"apiName": "chatupmobile",
"serviceName": "AppSync",
"defaultAuthType": {
"mode": "AMAZON_COGNITO_USER_POOLS",
"cognitoUserPoolId": "authchatupmobile23232e35"
},
"additionalAuthTypes": [
{
"mode": "API_KEY",
"expirationTime": 365,
"apiKeyExpirationDate": "2023-10-23T13:41:47.780Z",
"keyDescription": "ChatUpApiKey"
}
]
"mode": "API_KEY",
"expirationTime": 7
}
}
}
8 changes: 1 addition & 7 deletions amplify/backend/api/chatupmobile/parameters.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"AppSyncApiName": "chatupmobile",
"DynamoDBBillingMode": "PAY_PER_REQUEST",
"DynamoDBEnableServerSideEncryption": false,
"AuthCognitoUserPoolId": {
"Fn::GetAtt": [
"authchatupmobile23232e35",
"Outputs.UserPoolId"
]
}
"DynamoDBEnableServerSideEncryption": false
}
18 changes: 9 additions & 9 deletions amplify/backend/api/chatupmobile/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This "input" configures a global authorization rule to enable public access to
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
input AMPLIFY { globalAuthRule: AuthRule = { allow: public } } # FOR TESTING ONLY!
input AMPLIFY {
globalAuthRule: AuthRule = {allow: public}
}

type User @model {
type User @model @auth(rules: [{allow: public}]) {
id: ID!
name: String!
status: String
imageURL: String
isOnline: Boolean
messages: [Message] @hasMany(indexName: "byUser", fields:["id"])
messages: [Message] @hasMany(indexName: "byUser", fields: ["id"])
chatRooms: [ChatRoom] @manyToMany(relationName: "ChatRoomUser")
}

type Message @model {
type Message @model @auth(rules: [{allow: public}]) {
id: ID!
text: String!
chatRoomID: ID! @index(name: "byChatRoom", sortKeyFields: ["text"])
Expand All @@ -21,9 +21,9 @@ type Message @model {
sender: ChatRoom! @belongsTo(fields: ["senderID"])
}

type ChatRoom @model {
type ChatRoom @model @auth(rules: [{allow: public}]) {
id: ID!
messages: [Message] @hasMany(indexName: "byChatRoom", fields:["id"])
messages: [Message] @hasMany(indexName: "byChatRoom", fields: ["id"])
members: [User] @manyToMany(relationName: "ChatRoomUser")
lastMessage: Message @hasOne
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": "1",
"cognitoConfig": {
"identityPoolName": "chatupmobile23232e35_identitypool_23232e35",
"identityPoolName": "chatupmobile27b8e9b5_identitypool_27b8e9b5",
"allowUnauthenticatedIdentities": false,
"resourceNameTruncated": "chatup23232e35",
"userPoolName": "chatupmobile23232e35_userpool_23232e35",
"resourceNameTruncated": "chatup27b8e9b5",
"userPoolName": "chatupmobile27b8e9b5_userpool_27b8e9b5",
"autoVerifiedAttributes": [
"email"
],
Expand All @@ -31,12 +31,15 @@
"userpoolClientReadAttributes": [
"email"
],
"userpoolClientLambdaRole": "chatup23232e35_userpoolclient_lambda_role",
"userpoolClientLambdaRole": "chatup27b8e9b5_userpoolclient_lambda_role",
"userpoolClientSetAttributes": false,
"sharedId": "23232e35",
"resourceName": "chatupmobile23232e35",
"sharedId": "27b8e9b5",
"resourceName": "chatupmobile27b8e9b5",
"authSelections": "identityPoolAndUserPool",
"useDefault": "default",
"usernameAttributes": [
"email"
],
"userPoolGroupList": [],
"serviceName": "Cognito",
"usernameCaseSensitive": false,
Expand Down
33 changes: 9 additions & 24 deletions amplify/backend/backend-config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"auth": {
"chatupmobile23232e35": {
"chatupmobile27b8e9b5": {
"service": "Cognito",
"providerPlugin": "awscloudformation",
"dependsOn": [],
"customAuth": false,
"frontendAuthConfig": {
"socialProviders": [],
"usernameAttributes": [],
"usernameAttributes": [
"EMAIL"
],
"signupAttributes": [
"EMAIL"
],
Expand All @@ -29,33 +31,16 @@
"chatupmobile": {
"service": "AppSync",
"providerPlugin": "awscloudformation",
"dependsOn": [
{
"category": "auth",
"resourceName": "chatupmobile23232e35",
"attributes": [
"UserPoolId"
]
}
],
"dependsOn": [],
"output": {
"authConfig": {
"defaultAuthentication": {
"authenticationType": "AMAZON_COGNITO_USER_POOLS",
"userPoolConfig": {
"userPoolId": "authchatupmobile23232e35"
"authenticationType": "API_KEY",
"apiKeyConfig": {
"apiKeyExpirationDays": 7
}
},
"additionalAuthenticationProviders": [
{
"authenticationType": "API_KEY",
"apiKeyConfig": {
"apiKeyExpirationDays": 365,
"apiKeyExpirationDate": "2023-10-23T13:41:47.780Z",
"description": "ChatUpApiKey"
}
}
]
"additionalAuthenticationProviders": []
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/types/amplify-dependent-resources-ref.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type AmplifyDependentResourcesAttributes = {
"auth": {
"chatupmobile23232e35": {
"chatupmobile27b8e9b5": {
"IdentityPoolId": "string",
"IdentityPoolName": "string",
"UserPoolId": "string",
Expand Down
18 changes: 9 additions & 9 deletions amplify/team-provider-info.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"dev": {
"awscloudformation": {
"AuthRoleName": "amplify-chatupmobile-dev-131132-authRole",
"UnauthRoleArn": "arn:aws:iam::151995015007:role/amplify-chatupmobile-dev-131132-unauthRole",
"AuthRoleArn": "arn:aws:iam::151995015007:role/amplify-chatupmobile-dev-131132-authRole",
"AuthRoleName": "amplify-chatupmobile-dev-152751-authRole",
"UnauthRoleArn": "arn:aws:iam::151995015007:role/amplify-chatupmobile-dev-152751-unauthRole",
"AuthRoleArn": "arn:aws:iam::151995015007:role/amplify-chatupmobile-dev-152751-authRole",
"Region": "eu-central-1",
"DeploymentBucketName": "amplify-chatupmobile-dev-131132-deployment",
"UnauthRoleName": "amplify-chatupmobile-dev-131132-unauthRole",
"StackName": "amplify-chatupmobile-dev-131132",
"StackId": "arn:aws:cloudformation:eu-central-1:151995015007:stack/amplify-chatupmobile-dev-131132/d77214d0-52cb-11ed-bae9-060f0b36dfb8",
"AmplifyAppId": "d19voerwmkw5ja"
"DeploymentBucketName": "amplify-chatupmobile-dev-152751-deployment",
"UnauthRoleName": "amplify-chatupmobile-dev-152751-unauthRole",
"StackName": "amplify-chatupmobile-dev-152751",
"StackId": "arn:aws:cloudformation:eu-central-1:151995015007:stack/amplify-chatupmobile-dev-152751/0d4329f0-53a8-11ed-a3d3-0ac571183c98",
"AmplifyAppId": "d2dlym2700z4lq"
},
"categories": {
"auth": {
"chatupmobile23232e35": {}
"chatupmobile27b8e9b5": {}
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-community/netinfo": "^9.3.5",
"@react-native-community/netinfo": "9.3.0",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.1",
Expand Down
Loading

0 comments on commit 3301ffe

Please sign in to comment.