Skip to content

Commit

Permalink
Update jsonplaceholder (#82)
Browse files Browse the repository at this point in the history
* Update example for JSON Placeholder
  • Loading branch information
royderks authored Sep 8, 2023
1 parent 68dd75d commit 8f64c01
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
2 changes: 0 additions & 2 deletions with-jsonplaceholder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

This project builds a GraphQL API using the free [JSONPlaceholder](https://jsonplaceholder.typicode.com/) REST API, a free fake API for testing and prototyping.

[Try out the GraphQL API](https://public3b47822a17c9dda6.stepzen.net/api/with-jsonplaceholder)

## Getting Started

You'll need to create a [StepZen account](https://stepzen.com/signup) first. Once you've got that set up, [git clone](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone) this repository onto your machine and open the working directory:
Expand Down
44 changes: 22 additions & 22 deletions with-jsonplaceholder/jsonplaceholder/jsonplaceholder.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ type Post {
userId: ID!
user: User
@materializer(
query: "getUser"
query: "user"
arguments: [{ name: "id", field: "userId" }]
)
title: String
body: String
comments: [Comment]
@materializer(
query: "getComments"
query: "comments"
arguments: [{ name: "postId", field: "id" }]
)
}
Expand All @@ -28,13 +28,13 @@ type Album {
userId: ID!
user: User
@materializer(
query: "getUser"
query: "user"
arguments: [{ name: "id", field: "userId" }]
)
title: String
photos: [Photo]
@materializer(
query: "getAlbumPhotos"
query: "albumPhotos"
arguments: [{ name: "albumId", field: "id" }]
)
}
Expand All @@ -52,7 +52,7 @@ type Todo {
userId: ID!
user: User
@materializer(
query: "getUser"
query: "user"
arguments: [{ name: "id", field: "userId" }]
)
title: String
Expand All @@ -66,21 +66,21 @@ type User {
email: String
phone: String
website: String
address: Address @materializer(query: "getUserAddress")
company: Company @materializer(query: "getUserCompany")
address: Address @materializer(query: "userAddress")
company: Company @materializer(query: "userCompany")
posts: [Post]
@materializer(
query: "getUserPosts"
query: "userPosts"
arguments: [{ name: "userId", field: "id" }]
)
todos: [Todo]
@materializer(
query: "getUserTodos"
query: "userTodos"
arguments: [{ name: "userId", field: "id" }]
)
albums: [Album]
@materializer(
query: "getUserAlbums"
query: "userAlbums"
arguments: [{ name: "userId", field: "id" }]
)
}
Expand All @@ -101,9 +101,9 @@ type Company {
}

type Query {
getUser(id: ID!): User
user(id: ID!): User
@rest(endpoint: "https://jsonplaceholder.typicode.com/users/$id")
getUserAddress(id: ID!): Address
userAddress(id: ID!): Address
@rest(
endpoint: "https://jsonplaceholder.typicode.com/users/$id"
resultroot: "address"
Expand All @@ -112,30 +112,30 @@ type Query {
{ field: "longitude", path: "geo.lng" }
]
)
getUserCompany(id: ID!): Company
userCompany(id: ID!): Company
@rest(
endpoint: "https://jsonplaceholder.typicode.com/users/$id"
resultroot: "company"
)
getTodo(id: ID!): Todo
todo(id: ID!): Todo
@rest(endpoint: "https://jsonplaceholder.typicode.com/todos/$id")
getUserTodos(userId: ID!): [Todo]
userTodos(userId: ID!): [Todo]
@rest(endpoint: "https://jsonplaceholder.typicode.com/users/$userId/todos")
getPosts: [Post]
posts: [Post]
@rest(endpoint: "https://jsonplaceholder.typicode.com/posts")
getPost(id: ID!): Post
post(id: ID!): Post
@rest(endpoint: "https://jsonplaceholder.typicode.com/posts/$id")
getUserPosts(userId: ID!): [Post]
userPosts(userId: ID!): [Post]
@rest(endpoint: "https://jsonplaceholder.typicode.com/users/$userId/posts")
getAlbum(id: ID!): Album
album(id: ID!): Album
@rest(endpoint: "https://jsonplaceholder.typicode.com/albums/$id")
getUserAlbums(userId: ID!): [Album]
userAlbums(userId: ID!): [Album]
@rest(endpoint: "https://jsonplaceholder.typicode.com/users/$userId/albums")
getAlbumPhotos(albumId: ID!): [Photo]
albumPhotos(albumId: ID!): [Photo]
@rest(
endpoint: "https://jsonplaceholder.typicode.com/albums/$albumId/photos"
)
getComments(postId: ID!): [Comment]
comments(postId: ID!): [Comment]
@rest(
endpoint: "https://jsonplaceholder.typicode.com/posts/$postId/comments"
)
Expand Down
2 changes: 1 addition & 1 deletion with-neo4j/stepzen/sample.config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configurationset:
- configuration:
name: nyt
apiKey:
apiKey:

0 comments on commit 8f64c01

Please sign in to comment.