Skip to content

Commit d57c9e2

Browse files
committed
update repo structure
1 parent c9eb5b4 commit d57c9e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1687
-8823
lines changed

README.md

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,25 @@
1-
# Angular & GraphQL examples
1+
# angular-fullstack-graphql
22

3-
Code examples & starter kits to see how Angular works with GraphQL and other technologies.
3+
🚀 Starter projects for fullstack applications based on Angular & GraphQL.
44

5-
<hr>
5+
## Quickstart
66

7-
**<p align="center">Select an example** from the list above to get started ⤴️</p>
7+
**Select a boilerplate and follow the instructions in the belonging README to get started:**
88

9-
<hr>
9+
[**Apollo Client**](https://www.apollographql.com/client/):
1010

11-
<p align="center"><img src="http://imgur.com/yMEpKjP.png" /></p>
11+
- `minimal` (_coming soon_): Minimal boilerplate with basic "Hello World" functionality
12+
- [`basic`](./apollo-client/basic): Basic boilerplate based on a simple data model and with a GraphQL database
13+
- `advanced` (_coming soon_): Advanced boilerplate with a GraphQL database, authentication and realtime subscriptions
1214

13-
The examples above cover the following technologies:
15+
[**Relay Modern**](https://facebook.github.io/relay/):
1416

15-
* [GraphQL](http://graphql.org/)
16-
* [Apollo Client](http://dev.apollodata.com/react/)
17-
* [GraphQL subscriptions](https://www.graph.cool/docs/reference/simple-api/subscriptions-aip7oojeiv/)
18-
* ...
17+
- `minimal` (_coming soon_): Minimal boilerplate with basic "Hello World" functionality
18+
- `basic` (_coming soon_): Basic boilerplate based on a simple data model and with a GraphQL database
19+
- `advanced` (_coming soon_): Advanced boilerplate with a GraphQL database, authentication and realtime subscriptions
1920

20-
> Are you looking for another example? [Request it here](https://github.com/graphcool-examples/react-graphql/issues/new).
21+
> All projects are using [`graphql-yoga`](https://github.com/graphcool/graphql-yoga/) on the server-side.
2122
22-
## Tutorials
23+
## Contributing [![Slack Status](https://slack.graph.cool/badge.svg)](https://slack.graph.cool)
2324

24-
* [How to use `create-react-app` with GraphQL & Apollo](https://www.graph.cool/docs/tutorials/create-react-apps-with-apollo-client-aidae4aeg5/)
25-
* [Freecom: Building Intercom with GraphQL and Apollo](https://www.graph.cool/docs/tutorials/freecom-overview-intercom-tutorial-e8a6ajt8ax/)
26-
* [User Authentication with Auth0 for React and Apollo](https://www.graph.cool/docs/tutorials/react-apollo-auth0-pheiph4ooj/)
27-
* [Learn Relay](https://www.learnrelay.org/) / [Learn Apollo](https://www.learnapollo.com/)
28-
29-
## Contributors
30-
31-
A big thank you to all contributors and supporters of this repository 💚
32-
33-
<a href="https://github.com/nikolasburk/" target="_blank">
34-
<img src="https://github.com/nikolasburk.png?size=64" width="64" height="64" alt="nikolasburk">
35-
</a>
36-
<a href="https://github.com/schickling/" target="_blank">
37-
<img src="https://github.com/schickling.png?size=64" width="64" height="64" alt="schickling">
38-
</a>
39-
<a href="https://github.com/marktani/" target="_blank">
40-
<img src="https://github.com/marktani.png?size=64" width="64" height="64" alt="marktani">
41-
</a>
42-
<a href="https://github.com/kamilkisiela/" target="_blank">
43-
<img src="https://github.com/kamilkisiela.png?size=64" width="64" height="64" alt="kamilkisiela">
44-
</a>
45-
<a href="https://github.com/gsans/" target="_blank">
46-
<img src="https://github.com/gsans.png?size=64" width="64" height="64" alt="gsans">
47-
</a>
48-
<a href="https://github.com/sorenbs/" target="_blank">
49-
<img src="https://github.com/sorenbs.png?size=64" width="64" height="64" alt="sorenbs">
50-
</a>
51-
52-
## Help & Community [![Slack Status](https://slack.graph.cool/badge.svg)](https://slack.graph.cool)
53-
54-
Say hello in our [Slack](http://slack.graph.cool/) or visit the [Graphcool Forum](https://www.graph.cool/forum) if you run into issues or have questions. We love talking to you!
55-
56-
![](http://i.imgur.com/5RHR6Ku.png)
25+
Your feedback is **very helpful**, please share your opinion and thoughts! If you have any questions, join the [`#graphql-boilerplate`](https://graphcool.slack.com/messages/graphql-boilerplate) channel on our [Slack](https://graphcool.slack.com/).
File renamed without changes.

apollo-client/basic/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# angulars-fullstack-apollo-basic
2+
3+
🚀 Basic starter code for a fullstack app based on Angular, GraphQL & Apollo Client.
4+
5+
![](https://imgur.com/LG6r1q1.png)
6+
7+
## Technologies
8+
9+
* **Frontend**
10+
* [Angular](https://github.com/angular/angular): Frontend framework for building mobile and desktop web applications
11+
* [Apollo Client](https://github.com/apollographql/apollo-client): Fully-featured, production ready caching GraphQL client
12+
* **Backend**
13+
* [Graphcool](https://www.graph.cool): Powerful GraphQL database
14+
* [`graphql-yoga`](https://github.com/graphcool/graphql-yoga/): Fully-featured GraphQL server with focus on easy setup, performance & great developer experience
15+
* [`graphcool-binding`](https://github.com/graphcool/graphcool-binding): GraphQL binding for Graphcool services
16+
17+
## Requirements
18+
19+
You need to have the following things installed:
20+
21+
* Node 8+
22+
* Graphcool CLI: `npm i -g graphcool@beta`
23+
* GraphQL CLI: `npm i -g graphql-cli`
24+
* GraphQL Playground desktop app (optional): [Download](https://github.com/graphcool/graphql-playground/releases)
25+
26+
## Preview
27+
28+
![](http://imgur.com/3S6fUeI.gif)
29+
30+
## Getting started
31+
32+
```sh
33+
# Bootstrap GraphQL server in directory `my-app`, based on `angular-fullstack-basic` boilerplate
34+
graphql create my-app --boilerplate angular-fullstack-basic
35+
36+
# Navigate into the new project's `server` directory
37+
cd my-app/server
38+
39+
# Deploy the Graphcool database & start the server (runs on http://localhost:4000)
40+
yarn start
41+
42+
# Navigate back into the project's root directory and launch the Angular app
43+
cd ..
44+
yarn start # open http://localhost:3000 in your browser
45+
```
46+
47+
<details>
48+
49+
<summary>Alternative: Clone repo</summary>
50+
51+
```sh
52+
TODO
53+
```
54+
55+
</details>
56+
57+
## Docs
58+
59+
### Project structure
60+
61+
#### `/server`
62+
63+
- [`.graphqlconfig.yml`](./server/.graphqlconfig.yml) GraphQL configuration file containing the endpoints and schema configuration. Used by the [`graphql-cli`](https://github.com/graphcool/graphql-cli) and the [GraphQL Playground](https://github.com/graphcool/graphql-playground). See [`graphql-config`](https://github.com/graphcool/graphql-config) for more information.
64+
- [`graphcool.yml`](./server/graphcool.yml): The root configuration file for your database service ([documentation](https://www.graph.cool/docs/1.0/reference/graphcool.yml/overview-and-example-foatho8aip)).
65+
66+
#### `/server/database`
67+
68+
- [`database/datamodel.graphql`](./server/database/datamodel.graphql) contains the data model that you define for the project (written in [SDL](https://blog.graph.cool/graphql-sdl-schema-definition-language-6755bcb9ce51)).
69+
- [`database/schema.generated.graphql`](./server/database/schema.generated.graphql) defines the **database schema**. It contains the definition of the CRUD API for the types in your data model and is generated based on your `datamodel.graphql`. **You should never edit this file manually**, but introduce changes only by altering `datamodel.graphql` and run `graphcool deploy`.
70+
71+
#### `/server/src`
72+
73+
- [`src/schema.graphql`](src/schema.graphql) defines your **application schema**. It contains the GraphQL API that you want to expose to your client applications.
74+
- [`src/index.js`](src/index.js) is the entry point of your server, pulling everything together and starting the `GraphQLServer` from [`graphql-yoga`](https://github.com/graphcool/graphql-yoga).
75+
76+
### Common questions
77+
78+
#### I'm getting a 'Schema could not be fetched.' error after deploying, what gives?
79+
80+
Access to the Graphcool API is secured by a secret. This also applies to the introspection query. Using the latest version of GraphQL Playground, the `Authorization` header should automatically be setup with a proper JWT signing the secret. If that's not the case, you can follow these steps to access your API:
81+
82+
1. Visit http://jwtbuilder.jamiekurtz.com/
83+
1. Replace the `Key` at the bottom of the page with your `secret` from the [`graphcool.yml`](./server/graphcool.yml#L5)
84+
1. Click `Create signed JWT` and copy the obtained token
85+
1. Now, to access the schema, use the `Authorization: Bearer <token>` header, or in the GraphQL Playground set it as JSON:
86+
```json
87+
{
88+
"Authorization": "Bearer <token>"
89+
}
90+
```
91+
1. Reload the schema in the Playground (the _refresh_-button is located right next to the URL of the server)
92+
93+
> Note: Currently, no content of the signed JWT is verified by the database! This will be implemented [according to this proposal](https://github.com/graphcool/framework/issues/1365) at a later stage.
94+
95+
## Contributing
96+
97+
Your feedback is **very helpful**, please share your opinion and thoughts! If you have any questions, join the [`#graphql-boilerplate`](https://graphcool.slack.com/messages/graphql-boilerplate) channel on our [Slack](https://graphcool.slack.com/).

apollo-client/basic/install.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
module.exports = async ({ project }) => {
5+
const templateName = 'graphql-boilerplate'
6+
replaceInFile('server/src/index.js', templateName, project)
7+
replaceInFile('server/package.json', templateName, project)
8+
replaceInFile('server/graphcool.yml', templateName, project)
9+
10+
console.log(`\
11+
Next steps:
12+
13+
1. Change directory: \`cd ${project}/server\`
14+
2. Deploy database service: \`graphcool deploy\`
15+
3. Start local server: \`yarn start\` (you can now open a Playground at http://localhost:4000)
16+
4. Change directory: \`cd ..\`
17+
5. Start React app: \`yarn start\`
18+
6. Open browser: http://localhost:3000
19+
`)
20+
}
21+
22+
function replaceInFile(filePath, searchValue, replaceValue) {
23+
const contents = fs.readFileSync(filePath, 'utf8')
24+
const newContents = contents.replace(
25+
new RegExp(searchValue, 'g'),
26+
replaceValue,
27+
)
28+
fs.writeFileSync(filePath, newContents)
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.env*
2+
dist
3+
package-lock.json
4+
node_modules
5+
.idea
6+
.graphcoolrc
7+
.vscode
8+
*.log
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
projects:
2+
app:
3+
schemaPath: "src/schema.graphql"
4+
extensions:
5+
endpoints:
6+
default: "http://localhost:4000"
7+
database:
8+
schemaPath: "database/schema.generated.graphql"
9+
extensions:
10+
graphcool: graphcool.yml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Post {
2+
id: ID! @unique
3+
createdAt: DateTime!
4+
updatedAt: DateTime!
5+
description: String!
6+
imageUrl: String!
7+
}

0 commit comments

Comments
 (0)