-
Notifications
You must be signed in to change notification settings - Fork 122
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
Omitted Optional Parameters fails with error. #67
Comments
@GeertWille If you can submit a test for us to explain what you mean, I’d love to take a look! |
I think I've encountered thing as well. Heres a small example: gql`
query FilterItems(
$priceMin: Int
$priceMax: Int
) {
filterItems(
priceMin: $priceMin
priceMax: $priceMax
)
@rest(
type: "Item"
path: "filter?priceMax=:priceMax&priceMin=:priceMin"
) {
id
name
price
}
}
` So here I may or may not have priceMax and priceMin, but if I don't have them I will get the: Maybe there is an easy way to dynamically build up the query string somehow? |
does that still happen if you pass |
Yes confirmed now that it still happens with null values |
@HeyHugo What do you expect the If that's not what you expect, I don't think we can make the path omit undefined chunks and it would be clunky to provide a function to map the path. |
Hmm maybe this is crazy bad idea :) ..but what if instead of having the path inside the rest graphql directive the API was to provide a function somwhere taking the variables (and props?) as arguments and returning the path. |
I thought about that! -- We even have an example of the |
We could maybe have a registry of dynamic path-mappers at the RestLink-level, and have your |
Cool, yes that would cover my use case at least 👍 |
@HeyHugo -- I recommend opening a new GitHub issue to track that feature idea. If you have time & the inclination to help improve |
Ok, I'll make an attempt at this. Would be my first TypeScript code ever, so I'm expecting some bumps 😬 |
pathBuilder is a user provided function via a graphql variable to build up the path string. A use case it enables is having one or more optional query string parameters e.g: "/items/filter?minPrice=5&maxPrice=20" Here minPrice and maxPrice could be omitted See proposal in apollographql#69 and the problem it solves in apollographql#67
pathBuilder is a user provided function via a graphql variable to build up the path string. A use case it enables is having one or more optional query string parameters e.g: "/items/filter?minPrice=5&maxPrice=20" Here minPrice and maxPrice could be omitted See proposal in apollographql#69 and the problem it solves in apollographql#67
pathBuilder is a user provided function via a graphql variable to build up the path string. A use case it enables is having one or more optional query string parameters e.g: "/items/filter?minPrice=5&maxPrice=20" Here minPrice and maxPrice could be omitted See proposal in apollographql#69 and the problem it solves in apollographql#67
pathBuilder is a user provided function via a graphql variable to build up the path string. A use case it enables is having one or more optional query string parameters e.g: "/items/filter?minPrice=5&maxPrice=20" Here minPrice and maxPrice could be omitted See proposal in apollographql#69 and the problem it solves in apollographql#67
looks good to me! Thanks for the very fast response and PR 👍 |
Hello,
I have a case where I want to combine multiple parameters together to do a specific query. Some of them are optional but as soon as I trigger the query I always get a response that I have missing params to run the query. Is it possible that there is no support yet for optional params?
The text was updated successfully, but these errors were encountered: