Skip to content

feat: support operation validation via check command#706

Merged
tusharmath merged 58 commits intotailcallhq:mainfrom
tobihans:feat/check-operations
Jan 15, 2024
Merged

feat: support operation validation via check command#706
tusharmath merged 58 commits intotailcallhq:mainfrom
tobihans:feat/check-operations

Conversation

@tobihans
Copy link
Copy Markdown
Contributor

@tobihans tobihans commented Nov 30, 2023

Summary:
This PR add ability to check that the schema is able to execute some operations. It follows the second approach outlined in the issue.

It's worth noting that the validation depends on the queryValidation parameter of the @server directive, as the query is executed against the schema (with resolvers that don't actually do anything).

Given a the sample schema jsonplaceholder.graphql and two operations posts.graphql and empty.graphql, we get the output below.

# tc check jsonplaceholder.graphql --operations posts.graphql empty.graphql

N + 1: 1

Error: Validation Error
• Unknown field "userOd" on type "Post". Did you mean "userId", "user"? [examples/operations/posts.graphql, line 5 column 5]
• Unknown field "userAd" on type "Post". Did you mean "userId", "user"? [examples/operations/posts.graphql, line 6 column 5]
•  --> 1:1
  |
1 | 
  | ^---
  |
  = expected executable_definition [examples/operations/empty.graphql, line 1 column 1]

  • jsonplaceholder.graphql
schema
  @server(port: 8000, graphiql: true, hostname: "0.0.0.0", queryValidation: true)
  @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) {
  query: Query
}

type Query {
  posts: [Post] @http(path: "/posts")
}

type User {
  id: Int!
  name: String!
  username: String!
  email: String!
  phone: String
  website: String
}

type Post {
  id: Int!
  userId: Int!
  title: String!
  body: String!
  user: User @http(path: "/users/{{value.userId}}")
}
  • posts.graphql
query {
  posts {
    id
    body
    userOd
    userAd
  }
}
  • empty.graphql: well, it's empty

Issue Reference(s):
Fixes #416

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 (if applicable).
  • I have performed a self-review of my own code.

Fun fact:

I mistakenly deleted the branch, which closed the first PR I opened.

/claim #416

Copy link
Copy Markdown
Contributor

@wesleymatosdev wesleymatosdev left a comment

Choose a reason for hiding this comment

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

We need to find a way to write automated tests to this feature

@tobihans tobihans force-pushed the feat/check-operations branch from fb47ab6 to 9b07659 Compare December 1, 2023 21:49
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 4, 2023

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

@github-actions github-actions bot added the Stale label Dec 4, 2023
@tobihans tobihans force-pushed the feat/check-operations branch 2 times, most recently from e9bb7ee to 062f834 Compare December 4, 2023 23:06
@github-actions github-actions bot removed the Stale label Dec 5, 2023
@tobihans tobihans force-pushed the feat/check-operations branch 2 times, most recently from ebfa0cb to 2f86f4b Compare December 6, 2023 21:15
@tobihans tobihans force-pushed the feat/check-operations branch from 2f86f4b to 61d901c Compare December 7, 2023 21:32
@github-actions
Copy link
Copy Markdown

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

@github-actions github-actions bot added Stale and removed Stale labels Dec 11, 2023
@tobihans
Copy link
Copy Markdown
Contributor Author

Thanks for the branch update @tusharmath. I'm currently really sick. I hope to feel better soon and complete this. It remains to write automated tests like in graphql_spec.rs

@github-actions
Copy link
Copy Markdown

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

@github-actions github-actions bot added the Stale label Dec 15, 2023
@tobihans tobihans force-pushed the feat/check-operations branch from 9a574a5 to 441412b Compare January 13, 2024 21:33
@tusharmath tusharmath changed the title feat: pass operations to check command feat: support operation validations via check command Jan 14, 2024
@tusharmath tusharmath added ci: benchmark Runs benchmarks and removed ci: lint Automatically fix the linters issues and make a commit labels Jan 15, 2024
@tusharmath tusharmath changed the title feat: support operation validations via check command feat: support operation validation via check command Jan 15, 2024
@tusharmath tusharmath enabled auto-merge (squash) January 15, 2024 07:20
@tusharmath tusharmath disabled auto-merge January 15, 2024 07:33
@tusharmath tusharmath merged commit 242f3d4 into tailcallhq:main Jan 15, 2024
@tobihans tobihans deleted the feat/check-operations branch January 15, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Bounty claim ci: benchmark Runs benchmarks type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass operations to check command

7 participants