Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Reuter committed Jul 12, 2017
0 parents commit 164fac7
Show file tree
Hide file tree
Showing 23 changed files with 3,313 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": [
["inline-import", { "extensions": [".gql"] } ],
"inline-json-import"
],
"presets": [
"es2015",
"es2016"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GraphQL example for the DresdenJS.io meetup group.

Run `yarn run info` to list all available commands.
11 changes: 11 additions & 0 deletions examples/01-Article.schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# An article that can be viewed and ordered.
type Article {
# A text describing the details of the article.
description: String

# The ID of the article.
id: ID!

# The name of the article.
name: String!
}
27 changes: 27 additions & 0 deletions examples/02-QueryRoot.schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
schema {
query: QueryRoot
}

# An article that can be viewed and ordered.
type Article {
# A text describing the details of the article.
description: String

# The ID of the article.
id: ID!

# The name of the article.
name: String!
}

# A catalog containing articles.
type QueryRoot {
# Finds a specific article listed in the catalog.
article(
# The ID of the article.
articleId: ID!
): Article

# Lists all available articles in the catalog.
articles: [Article]
}
7 changes: 7 additions & 0 deletions examples/03-Articles.query.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query All {
articles {
id
name
description
}
}
42 changes: 42 additions & 0 deletions examples/03-Category.schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
schema {
query: QueryRoot
}

# An article that can be viewed and ordered.
type Article {
# The category this article belongs to.
category: Category!

# A text describing the details of the article.
description: String

# The ID of the article.
id: ID!

# The name of the article.
name: String!
}

# A category that groups multiple articles.
enum Category {
# Physical books.
BOOKS

# Electronic devices.
DEVICES
}

# A catalog containing articles.
type QueryRoot {
# Finds a specific article listed in the catalog.
article(
# The ID of the article.
articleId: ID!
): Article

# Lists all available articles in the catalog.
articles(
# The category to list articles from. Can be omitted to not filter by category.
category: Category
): [Article]
}
7 changes: 7 additions & 0 deletions examples/04-Books.query.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query Books {
articles(category: BOOKS) {
id
name
category
}
}
45 changes: 45 additions & 0 deletions examples/05-Recommendations.schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
schema {
query: QueryRoot
}

# An article that can be viewed and ordered.
type Article {
# The category this article belongs to.
category: Category!

# A text describing the details of the article.
description: String

# The ID of the article.
id: ID!

# The name of the article.
name: String!

# Articles recommended to buy along with this one.
recommendations: [Article]
}

# A category that groups multiple articles.
enum Category {
# Physical books.
BOOKS

# Electronic devices.
DEVICES
}

# A catalog containing articles.
type QueryRoot {
# Finds a specific article listed in the catalog.
article(
# The ID of the article.
articleId: ID!
): Article

# Lists all available articles in the catalog.
articles(
# The category to list articles from. Can be omitted to not filter by category.
category: Category
): [Article]
}
10 changes: 10 additions & 0 deletions examples/06-Recommendations.query.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query Recommendations {
article(articleId: "1") {
id
name
recommendations {
id
name
}
}
}
69 changes: 69 additions & 0 deletions examples/07-Reviews.schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
schema {
query: QueryRoot
}

# An article that can be viewed and ordered.
type Article {
# The category this article belongs to.
category: Category!

# A text describing the details of the article.
description: String

# The ID of the article.
id: ID!

# The name of the article.
name: String!

# The average rating of this article.
rating: Float

# Articles recommended to buy along with this one.
recommendations: [Article]

# The reviews posted for this article.
reviews: [Review]
}

# A category that groups multiple articles.
enum Category {
# Physical books.
BOOKS

# Electronic devices.
DEVICES
}

# A catalog containing articles.
type QueryRoot {
# Finds a specific article listed in the catalog.
article(
# The ID of the article.
articleId: ID!
): Article

# Lists all available articles in the catalog.
articles(
# The category to list articles from. Can be omitted to not filter by category.
category: Category
): [Article]
}

# A review posted for an article.
type Review {
# The author of the review.
author: String

# The ISO 8601 date when the review has been posted.
date: String

# The ID of the review.
id: ID!

# The rating behind this review.
rating: Int!

# The review text.
text: String
}
14 changes: 14 additions & 0 deletions examples/08-Reviews.query.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
query Reviews {
article(articleId: "5") {
id
name
rating
reviews {
id
author
date
rating
text
}
}
}
91 changes: 91 additions & 0 deletions examples/09-Mutation.schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
schema {
query: QueryRoot
mutation: MutationRoot
}

# An article that can be viewed and ordered.
type Article {
# The category this article belongs to.
category: Category!

# A text describing the details of the article.
description: String

# The ID of the article.
id: ID!

# The name of the article.
name: String!

# The average rating of this article.
rating: Float

# Articles recommended to buy along with this one.
recommendations: [Article]

# The reviews posted for this article.
reviews: [Review]
}

# A category that groups multiple articles.
enum Category {
# Physical books.
BOOKS

# Electronic devices.
DEVICES
}

# The mutation root.
type MutationRoot {
# Posts a new review on an article.
postReview(
# The ID of the article.
articleId: ID!

# The input for posting the review.
review: ReviewInput!
): Article
}

# A catalog containing articles.
type QueryRoot {
# Finds a specific article listed in the catalog.
article(
# The ID of the article.
articleId: ID!
): Article

# Lists all available articles in the catalog.
articles(
# The category to list articles from. Can be omitted to not filter by category.
category: Category
): [Article]
}

# A review posted for an article.
type Review {
# The author of the review.
author: String

# The ISO 8601 date when the review has been posted.
date: String

# The ID of the review.
id: ID!

# The rating behind this review.
rating: Int!

# The review text.
text: String
}

# The input for reviewing an article.
input ReviewInput {
# The rating behind the review.
rating: Int!

# The review text.
text: String
}
18 changes: 18 additions & 0 deletions examples/10-PostReview.mutation.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
mutation PostReview {
postReview(
articleId: "2",
review: {
rating: 3
text: "meh"
}
) {
id
name
rating
reviews {
id
text
rating
}
}
}
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"scripts": {
"sync-schema": "babel-node sync-schema.js",
"info": "npm-scripts-info",
"start": "opn http://localhost:3000/graphql && nodemon src/server.js --exec babel-node --ext js,gql"
},
"scripts-info": {
"sync-schema": "Generate the schema.gql file from the schema defined in schema.js.",
"info": "Print this info.",
"start": "Starts the server, opens GraphiQL in the browser and watches for source file changes."
},
"dependencies": {
"babel-cli": "^6.24.0",
"babel-plugin-inline-import": "^2.0.4",
"babel-plugin-inline-json-import": "^0.2.1",
"babel-preset-es2015": "^6.24.0",
"babel-preset-es2016": "^6.22.0",
"express": "^4.15.2",
"express-graphql": "^0.6.3",
"graphql": "^0.9.1",
"lodash": "^4.17.4",
"npm-scripts-info": "^0.3.6",
"opn-cli": "^3.1.0"
},
"devDependencies": {
"nodemon": "^1.11.0"
}
}
Loading

0 comments on commit 164fac7

Please sign in to comment.