tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

Pass `operations` to `check` command

Open tobihans opened this issue 2 years ago • 5 comments

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

Operation examples/operations/posts.graphql: 2 errors found
1. Unknown field "userOd" on type "Post". Did you mean "userId", "user"?
2. Unknown field "userAd" on type "Post". Did you mean "userId", "user"?

Operation examples/operations/empty.graphql: 1 errors found
1.  --> 1:1
  |
1 | 
  | ^---
  |
  = expected executable_definition

  • 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:

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

Checklist:

  • [x] I have added relevant unit & integration tests.
  • [x] I have updated the documentation accordingly (if applicable).
  • [x] 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

tobihans avatar Nov 30 '23 18:11 tobihans

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

github-actions[bot] avatar Dec 04 '23 22:12 github-actions[bot]

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

github-actions[bot] avatar Dec 11 '23 21:12 github-actions[bot]

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

tobihans avatar Dec 13 '23 12:12 tobihans

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

github-actions[bot] avatar Dec 15 '23 13:12 github-actions[bot]

@tobihans Hey, could you please update us on the status of the pr?

meskill avatar Jan 02 '24 10:01 meskill

@tobihans Hey, could you please update us on the status of the pr?

I'll ask for a review in one day or two. Thanks.

tobihans avatar Jan 03 '24 08:01 tobihans

Codecov Report

Attention: 97 lines in your changes are missing coverage. Please review.

Comparison is base (0bb20a2) 90.40% compared to head (81edf91) 89.63%.

Files Patch % Lines
src/blueprint/operation.rs 0.00% 39 Missing :warning:
src/cli/tc.rs 0.00% 24 Missing :warning:
src/blueprint/blueprint.rs 43.47% 13 Missing :warning:
src/cli/server/server.rs 0.00% 8 Missing :warning:
src/main.rs 0.00% 6 Missing :warning:
src/cli/file.rs 28.57% 5 Missing :warning:
src/cli/command.rs 0.00% 1 Missing :warning:
src/cli/server/http_1.rs 50.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #706      +/-   ##
==========================================
- Coverage   90.40%   89.63%   -0.78%     
==========================================
  Files          84       85       +1     
  Lines        8394     8471      +77     
==========================================
+ Hits         7589     7593       +4     
- Misses        805      878      +73     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 04 '24 05:01 codecov[bot]

Can you resolve the conflicts

ssddOnTop avatar Jan 12 '24 08:01 ssddOnTop

Can you resolve the conflicts

Yes, I'll do it soon. Thanks

tobihans avatar Jan 12 '24 10:01 tobihans