Skip to content

Commit

Permalink
more setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ccabo1 committed Sep 8, 2018
1 parent ff72dbc commit 9b75590
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# React-GraphQL

How to follow along:
Hi there! Let's learn some more about React and GraphQL. If you want to follow along, do the following:

0. Check out [this Apollo Launchpad](https://launchpad.graphql.com/0vp11m31k5). We will use this as our server to pull data.
1. Clone this repository
2. `yarn install` or `npm install`
3. `yarn start` or `npm start`
4. Go to `localhost:3000` in your browser
5. Follow along or forge your own path :)

--------------------

### More about this repo

* This is effectively `creat-react-app` with a little clean up, some styles, and some packages to make getting up and running with GraphQL easier.
* All code regarding making queries and rendering stuff goes down in the `/components` folder.
* All code regarding setting up the app goes down in `index.js` and `App.js`.
12 changes: 6 additions & 6 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.App {
.app {
text-align: center;
}

.App-header {
.header {
background-color: #222;
padding: 2rem 0rem;
color: white;
}

.App-title {
font-size: 1.5em;
.title {
font-size: 2em;
}

.App-intro {
font-size: 1.25em;
p {
font-size: 2em;
}
11 changes: 4 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React from 'react';
import ApolloClient from 'apollo-boost';
import { ApolloProvider } from 'react-apollo';

Expand All @@ -12,13 +12,10 @@ const client = new ApolloClient({

const App = () => (
<ApolloProvider client={client}>
<div className="App">
<header className="App-header">
<h1 className="App-title">Welcome to React with GraphQL</h1>
<div className="app">
<header className="header">
<h1 className="title">Welcome to React with GraphQL</h1>
</header>
<p className="App-intro">
This should be fun!
</p>
<Workshops />
</div>
</ApolloProvider>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Workshop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

// Let's build this out some more
// Doesn't do too much at the moment
const Workshop = () => (
<p>This is the best workshop ever!</p>
);
Expand Down
14 changes: 8 additions & 6 deletions src/components/Workshops.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React from 'react';

// This is a component we import to make queries with GraphQL
import { Query } from 'react-apollo';

// We use this to actually type and format our query
import gql from 'graphql-tag';

const Workshops = () => (
<Query query={gql`
{
workshops {
title
}
hello
}
`}>
{({ loading, error, data }) => {
if (loading) return (<p>Loading...</p>);
if (error) return (<p>There was an error :(</p>);
return (<p>We have some data! πŸ§šβ€πŸ„πŸ»</p>)
if (loading) return (<p>Loading... πŸ˜•</p>);
if (error) return (<p>There was an error 😩</p>);
return (<p>{data.hello} 🀠</p>)
}}
</Query>
);
Expand Down

0 comments on commit 9b75590

Please sign in to comment.