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

implement read-only native queries with no arguments #5

Merged
merged 17 commits into from
Mar 20, 2024

Conversation

hallettj
Copy link
Collaborator

@hallettj hallettj commented Mar 18, 2024

Implements read-only native queries without arguments. I added a test query called hello to the fixtures. If you run with arion up -d and access graphiql at http://localhost:7100/ you can try it out.

I also added on objectTypes field to native query definitions. Object types defined there are merged with object types in schema.json so that users can keep hand-written types separate from generated ones.

I made some changes to directory.rs to add more context to configuration-parsing errors in a couple of spots. If we just stick to io::Error errors the messages end up being not very helpful.

Still to do in follow-up PRs:

  • implement arguments
  • add mutation capability to the connector
  • add a mutation endpoint to handle procedures

Ticket: https://hasurahq.atlassian.net/browse/MDB-85

@hallettj hallettj changed the title Jesse/native queries in query handler implement read-only native queries with no arguments Mar 18, 2024
.flat_map(|native_query| &native_query.object_types),
);
let object_types = object_types_from_schema
.chain(object_types_from_native_queries)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we check anywhere that there are no duplicate object type names?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point; I added a validating constructor

@hallettj hallettj requested a review from dmoverton March 18, 2024 20:14
let database = config.client.database(&config.database);

let target = &query_request.target;
if let Some(native_query) = config.native_queries.iter().find(|query| {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine for now, but linear search (i.e. find) could lead to performance problems for users who have a lot of native queries. These should eventually be stored in some sort of hashmap.

Copy link
Contributor

@dmoverton dmoverton left a comment

Choose a reason for hiding this comment

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

Looks good.

@hallettj hallettj merged commit 76a3317 into main Mar 20, 2024
2 checks passed
@hallettj hallettj deleted the jesse/native-queries-in-query-handler branch March 20, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants