This file contains hidden or 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
import React, { Component } from 'react'; | |
import { StyleSheet, Text, View, Button, Modal, TextInput } from 'react-native'; | |
import { ApolloClient, HttpLink, InMemoryCache } from 'apollo-boost'; | |
import { ApolloProvider, graphql, Mutation } from 'react-apollo'; | |
import gql from 'graphql-tag'; | |
const client = new ApolloClient({ | |
link: new HttpLink({ | |
uri: 'https://eu1.prisma.sh/natalia-majkowska/dogs-service/dev', | |
headers: { |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import { StyleSheet, View, ScrollView } from 'react-native'; | |
import { LoginScreen } from './LoginScreen'; | |
import { DogsScreen } from './DogsScreen'; | |
export default class App extends Component { | |
render() { | |
return ( | |
<ScrollView style={styles.scroll}> | |
<View style={styles.container}> |
This file contains hidden or 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
const Mutation = require('./Mutations'); | |
const resolvers = { | |
Query: { | |
dogName: () => `Tommy the chihuahua`, | |
dogs: (root, args, context, queryInfo) => { | |
return context.db.query.dogs({}, queryInfo); | |
}, | |
user: (root, args, context, info) => { | |
return context.db.query.user({ where: { id: root.user.id } }, info); |
This file contains hidden or 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
const APP_SECRET = 'abcdefghijklmnopqrst'; | |
const bcrypt = require('bcryptjs'); | |
const jwt = require('jsonwebtoken'); | |
signUp = async (_object, args, context, _information) => { | |
const password = await bcrypt.hash(args.password, 10); | |
const user = await context.db.mutation.createUser( | |
{ | |
data: { ...args, password } | |
}, |
This file contains hidden or 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 Dog { | |
id: ID! @unique | |
name: String! | |
type: String! | |
} | |
type User { | |
id: ID! @unique | |
name: String! | |
password: String! |
This file contains hidden or 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 Dog { | |
id: ID! @unique | |
name: String! | |
type: String! | |
} | |
type User { | |
id: ID! @unique | |
name: String! | |
password: String! |
This file contains hidden or 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
render() { | |
return ( | |
<ApolloProvider client={client}> | |
<View style={styles.container}> | |
<Mutation mutation={addDog} refetchQueries={[{ query: dogQuery }]}> | |
{(addDogMutation, { data }) => ( | |
<View> | |
<Text style={styles.welcome}>Dogs data:</Text> | |
<TextInput | |
style={styles.input} |
This file contains hidden or 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
const addDog = gql` | |
mutation addDog($type: String!, $name: String!) { | |
createDog(data: { type: $type, name: $name }) { | |
id | |
} | |
} | |
`; |
This file contains hidden or 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
import { ApolloProvider, graphql, Mutation } from 'react-apollo'; |
This file contains hidden or 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
<View> | |
<Text style={styles.welcome}>Dogs data:</Text> | |
<TextInput | |
style={styles.input} | |
onChangeText={text => this.setState({ name: text })} | |
value={this.state.name} | |
placeholder="name/> | |
<TextInput |