Created
February 22, 2020 00:33
-
-
Save undefobj/00b5b4f61ae36619716043f89fb6aa50 to your computer and use it in GitHub Desktop.
Repro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* | |
* @format | |
* @flow | |
*/ | |
import React, { useEffect } from 'react'; | |
import { | |
SafeAreaView, | |
StyleSheet, | |
ScrollView, | |
View, | |
Text, | |
StatusBar, | |
} from 'react-native'; | |
import { | |
Header, | |
LearnMoreLinks, | |
Colors, | |
DebugInstructions, | |
ReloadInstructions, | |
} from 'react-native/Libraries/NewAppScreen'; | |
import AWSAppSyncClient from 'aws-appsync' | |
import AppSyncConfig from './aws-exports' | |
import graphql from 'graphql-tag'; | |
import { listTodos } from './src/graphql/queries'; | |
import { createTodo } from './src/graphql/mutations'; | |
const client = new AWSAppSyncClient({ | |
url: AppSyncConfig.aws_appsync_graphqlEndpoint, | |
region: AppSyncConfig.aws_appsync_region, | |
auth: { | |
type: AppSyncConfig.aws_appsync_authenticationType, | |
apiKey: AppSyncConfig.aws_appsync_apiKey, | |
// jwtToken: async () => token, // Required when you use Cognito UserPools OR OpenID Connect. token object is obtained previously | |
} | |
}) | |
const App: () => React$Node = () => { | |
useEffect(()=>{ | |
client.query({ | |
query: graphql(listTodos), | |
variables: { | |
limit: 100 | |
} | |
}).then( (c) => { | |
console.log(`items: `, c.data.listTodos.items); | |
}) | |
// client.mutate({ | |
// mutation: graphql(createTodo), | |
// //fetchPolicy: 'cache-and-network', | |
// variables: { | |
// input: { | |
// name: 'Use AppSync', | |
// description: 'Realtime and Offline', | |
// } | |
// } | |
// }).then( (res) => { | |
// console.log(`DATA:`, res); | |
// }); | |
}, []); | |
return ( | |
<> | |
<StatusBar barStyle="dark-content" /> | |
<SafeAreaView> | |
<ScrollView> | |
<Text> | |
Hello | |
</Text> | |
</ScrollView> | |
</SafeAreaView> | |
</> | |
); | |
}; | |
const styles = StyleSheet.create({ | |
scrollView: { | |
backgroundColor: Colors.lighter, | |
}, | |
engine: { | |
position: 'absolute', | |
right: 0, | |
}, | |
body: { | |
backgroundColor: Colors.white, | |
}, | |
sectionContainer: { | |
marginTop: 32, | |
paddingHorizontal: 24, | |
}, | |
sectionTitle: { | |
fontSize: 24, | |
fontWeight: '600', | |
color: Colors.black, | |
}, | |
sectionDescription: { | |
marginTop: 8, | |
fontSize: 18, | |
fontWeight: '400', | |
color: Colors.dark, | |
}, | |
highlight: { | |
fontWeight: '700', | |
}, | |
footer: { | |
color: Colors.dark, | |
fontSize: 12, | |
fontWeight: '600', | |
padding: 4, | |
paddingRight: 12, | |
textAlign: 'right', | |
}, | |
}); | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
// this is an auto generated file. This will be overwritten | |
export const createTodo = `mutation CreateTodo( | |
$input: CreateTodoInput! | |
$condition: ModelTodoConditionInput | |
) { | |
createTodo(input: $input, condition: $condition) { | |
id | |
name | |
description | |
} | |
} | |
`; | |
export const updateTodo = `mutation UpdateTodo( | |
$input: UpdateTodoInput! | |
$condition: ModelTodoConditionInput | |
) { | |
updateTodo(input: $input, condition: $condition) { | |
id | |
name | |
description | |
} | |
} | |
`; | |
export const deleteTodo = `mutation DeleteTodo( | |
$input: DeleteTodoInput! | |
$condition: ModelTodoConditionInput | |
) { | |
deleteTodo(input: $input, condition: $condition) { | |
id | |
name | |
description | |
} | |
} | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "repro", | |
"version": "0.0.1", | |
"private": true, | |
"scripts": { | |
"android": "react-native run-android", | |
"ios": "react-native run-ios", | |
"start": "react-native start", | |
"test": "jest", | |
"lint": "eslint ." | |
}, | |
"dependencies": { | |
"@react-native-community/netinfo": "4", | |
"aws-appsync": "2.0.0", | |
"graphql-tag": "^2.10.3", | |
"react": "16.9.0", | |
"react-native": "0.61.5" | |
}, | |
"devDependencies": { | |
"@babel/core": "^7.6.2", | |
"@babel/runtime": "^7.6.2", | |
"@react-native-community/eslint-config": "^0.0.5", | |
"babel-jest": "^24.9.0", | |
"eslint": "^6.5.1", | |
"jest": "^24.9.0", | |
"metro-react-native-babel-preset": "^0.56.0", | |
"react-test-renderer": "16.9.0" | |
}, | |
"jest": { | |
"preset": "react-native" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getTodo = `query GetTodo($id: ID!) { | |
getTodo(id: $id) { | |
id | |
name | |
description | |
} | |
} | |
`; | |
export const listTodos = `query ListTodos( | |
$filter: ModelTodoFilterInput | |
$limit: Int | |
$nextToken: String | |
) { | |
listTodos(filter: $filter, limit: $limit, nextToken: $nextToken) { | |
items { | |
id | |
name | |
description | |
} | |
} | |
} | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Todo @model { | |
id: ID! | |
name: String! | |
description: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment