-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
.flat_map(|native_query| &native_query.object_types), | ||
); | ||
let object_types = object_types_from_schema | ||
.chain(object_types_from_native_queries) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
let database = config.client.database(&config.database); | ||
|
||
let target = &query_request.target; | ||
if let Some(native_query) = config.native_queries.iter().find(|query| { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Implements read-only native queries without arguments. I added a test query called
hello
to the fixtures. If you run witharion 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 inschema.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 toio::Error
errors the messages end up being not very helpful.Still to do in follow-up PRs:
Ticket: https://hasurahq.atlassian.net/browse/MDB-85