-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Version Information
Server Version: Tried 2.6.2, 2.7.0 and 2.8.0-beta.1
CLI Version (for CLI related issue): N/A
Environment
OSS
What is the expected behaviour?
For a GraphQL query where a parameter is optional, I would like to be able to configure a REST API connector to optionally utilize this field.
Dummy example:
type Query {
getBlogPosts(type: [String]) : BlogPost
}query {
allBlogPosts: getBlogPosts() {
id
title
}
tutorials: getBlogPosts(type: ["tutorial"]) {
id
title
}
}Connecting to a REST API at example.org/blog, I would like to be able to configure that allBlogPosts executes GET example.org/blog and tutorials example.org/blog?type=tutorial
Keywords
REST connection optional nullable
What is the current behaviour?
It currently cannot handle parameters being optional in any way: allBlogPosts in my example would give an error Cannot interpolate type: 'Null'.. It is not possible to handle that with the Kriti templating language either, since both if-statements and defaulting operator are not recognized as valid syntax.
How to reproduce the issue?
- Create a REST API that has optional parameters
- In Hasura, add a new action
a. Use an action definition where a parameter is optional
b. Map that parameter to a query string parameter - Execute a query where the optional parameter is skipped
Screenshots or Screencast
Please provide any traces or logs that could help here.
Any possible solutions?
Hasura should be able to at least handle a Null value in order to create a "valid" HTTP request. Whether it is correctly interpreted by the receiving server is another issue.
In my example, the minimum behavior Hasura should be able to do is to construct example.org/blog?type.
Better behavior would be to be able to declare for every query parameter what the behavior should be on Null values: omit, include only as key (?type), include as key with no value (?type=).
Can you identify the location in the source code where the problem exists?
I have not checked, we are currently looking into StepZen instead of Hasura since I have a working example in there.
If the bug is confirmed, would you be willing to submit a PR?
As above, we're looking into alternative tooling, so it's highly unlikely that we're dedicating time to solve the bug.