Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(390): Add JSONPlaceholder configurations #2741

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

onyedikachi-david
Copy link

Summary:
Add JSONPlaceholder example configurations for GraphQL, YAML, and JSON formats.

Issue Reference(s):
Related to tailcallhq/tailcallhq.github.io#390

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

Additional Context:
This PR adds example configurations for the JSONPlaceholder API as discussed in tailcallhq/tailcallhq.github.io#390. These examples demonstrate how to set up a Tailcall configuration for a complex API with multiple interconnected resources.

The configurations are added in three formats:

  • GraphQL: examples/jsonplaceholder.graphql
  • YAML: examples/jsonplaceholder.yml
  • JSON: examples/jsonplaceholder.json

These examples will be referenced in the documentation (tailcallhq/tailcallhq.github.io) to provide users with a comprehensive starting point for using Tailcall with a real-world API.

@onyedikachi-david onyedikachi-david changed the title Add JSONPlaceholder example configurations feat(390): Add JSONPlaceholder configurations Aug 21, 2024
@onyedikachi-david onyedikachi-david marked this pull request as ready for review August 21, 2024 12:35
Copy link

Action required: PR inactive for 5 days.
Status update or closure in 10 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Aug 26, 2024
@tusharmath
Copy link
Contributor

tusharmath commented Aug 26, 2024

Thanks @onyedikachi-david ! I tried running the configuration as above and got these errors:

 tailcall start ./examples/jsonplaceholder.graphql
 INFO Env file: "/Users/tushar/Documents/Projects/tailcall/.env" loaded
 WARN A new release of tailcall is available: v0.104.0 ➜ v0.104.18
 WARN To upgrade, run: npm update -g @tailcallhq/tailcall
 WARN https://github.com/tailcallhq/tailcall/releases/tag/v0.104.18
 INFO File read: ./examples/jsonplaceholder.graphql ... ok
 INFO N + 1 detected: 34
ERROR Invalid Configuration
Caused by:
  • argument 'album' is a nullable type [at Album.photos.@[email protected]]
  • argument 'user' is a nullable type [at ComplexQuery.userWithPostsAndComments.@[email protected]]
  • argument 'post' is a nullable type [at ComplexQuery.userWithPostsAndComments.@[email protected]]
  • argument 'post' is a nullable type [at Post.comments.@[email protected]]
  • argument 'user' is a nullable type [at [email protected]]
  • argument 'post' is a nullable type [at [email protected]]
  • argument 'album' is a nullable type [at [email protected]]
  • argument 'user' is a nullable type [at [email protected]]
  • argument 'user' is a nullable type [at [email protected]]
  • argument 'user' is a nullable type [at User.albums.@[email protected]]
  • argument 'user' is a nullable type [at User.posts.@[email protected]]
  • argument 'user' is a nullable type [at User.todos.@[email protected]]

@tusharmath tusharmath marked this pull request as draft August 26, 2024 14:18
@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Aug 26, 2024
@tusharmath
Copy link
Contributor

Moving to draft to reduce noise and improve CI efficiency. Once you are ready just mark it as "ready to review". Feel free to give a shoutout on the #contributors channel on Discord if you want immediate attention.

@github-actions github-actions bot removed the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Aug 26, 2024
Signed-off-by: David Anyatonwu <[email protected]>
…thub.com/onyedikachi-david/tailcall into examples/update-jsonplaceholder-examples

fixes tailcall check failure for updated examples.
@onyedikachi-david
Copy link
Author

Thanks @onyedikachi-david ! I tried running the configuration as above and got these errors:

 tailcall start ./examples/jsonplaceholder.graphql
 INFO Env file: "/Users/tushar/Documents/Projects/tailcall/.env" loaded
 WARN A new release of tailcall is available: v0.104.0 ➜ v0.104.18
 WARN To upgrade, run: npm update -g @tailcallhq/tailcall
 WARN https://github.com/tailcallhq/tailcall/releases/tag/v0.104.18
 INFO File read: ./examples/jsonplaceholder.graphql ... ok
 INFO N + 1 detected: 34
ERROR Invalid Configuration
Caused by:
  • argument 'album' is a nullable type [at Album.photos.@[email protected]]
  • argument 'user' is a nullable type [at ComplexQuery.userWithPostsAndComments.@[email protected]]
  • argument 'post' is a nullable type [at ComplexQuery.userWithPostsAndComments.@[email protected]]
  • argument 'post' is a nullable type [at Post.comments.@[email protected]]
  • argument 'user' is a nullable type [at [email protected]]
  • argument 'post' is a nullable type [at [email protected]]
  • argument 'album' is a nullable type [at [email protected]]
  • argument 'user' is a nullable type [at [email protected]]
  • argument 'user' is a nullable type [at [email protected]]
  • argument 'user' is a nullable type [at User.albums.@[email protected]]
  • argument 'user' is a nullable type [at User.posts.@[email protected]]
  • argument 'user' is a nullable type [at User.todos.@[email protected]]

Thanks for your review sir. Just fixed it.

@onyedikachi-david onyedikachi-david marked this pull request as ready for review August 27, 2024 20:24
# Fetch a post by ID
post(id: Int!): Post @http(path: "/posts/{{.args.id}}")
# Fetch all posts by a specific user
posts(user: Int!): [Post] @http(path: "/posts?userId={{.args.user}}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
posts(user: Int!): [Post] @http(path: "/posts?userId={{.args.user}}")
posts(userId: Int): [Post] @http(path: "/posts?userId={{.args.user}}")

User should be optional. This is true for all the types that return a list of values. Please update the arguments and drop required.

# Fetch a comment by ID
comment(id: Int!): Comment @http(path: "/comments/{{.args.id}}")
# Fetch all comments on a specific post
comments(post: Int!): [Comment] @http(path: "/comments?postId={{.args.post}}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
comments(post: Int!): [Comment] @http(path: "/comments?postId={{.args.post}}")
comments(postId: Int, email: String): [Comment] @http(path: "/comments?postId={{.args.post}}")

# Define the Mutation type with various fields for creating, updating, and deleting resources
type Mutation {
# Create a new post
createPost(input: PostInput!): Post @http(method: "POST", path: "/posts", body: "{{.args.input}}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
createPost(input: PostInput!): Post @http(method: "POST", path: "/posts", body: "{{.args.input}}")
createPost(input: PostInput!): Post @http(method: POST, path: "/posts", body: "{{.args.input}}")

Methods are not set in string. They are enums.

@tusharmath tusharmath marked this pull request as draft September 1, 2024 05:10
@tusharmath
Copy link
Contributor

Moving to draft to reduce noise and improve CI efficiency. Once you are ready just mark it as "ready to review". Feel free to give a shoutout on the #contributors channel on Discord if you want immediate attention.

Copy link

github-actions bot commented Sep 6, 2024

Action required: PR inactive for 5 days.
Status update or closure in 10 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants