Comments (12)
@GeertWille If you can submit a test for us to explain what you mean, Iβd love to take a look!
from apollo-link-rest.
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:
Missing params to run query error...
Maybe there is an easy way to dynamically build up the query string somehow?
from apollo-link-rest.
does that still happen if you pass null
for that parameter to the variables
hash?
from apollo-link-rest.
Yes confirmed now that it still happens with null values
from apollo-link-rest.
@HeyHugo What do you expect the path:
to be turned into?
filter?priceMax=undefined&priceMin=5
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.
from apollo-link-rest.
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.
from apollo-link-rest.
I thought about that! -- We even have an example of the bodyBuilder
as a function -- the problem is that a fundamental feature of apollo-link-rest
is that you can @rest(path: "filterβ¦")
on any level of any GraphQL query. The result is that you'd have to provide your pathMapper
-function as a variable that you pass in to all the queries that use @rest(path: "filterβ¦")
-- that would be really clunky. :(
from apollo-link-rest.
We could maybe have a registry of dynamic path-mappers at the RestLink-level, and have your @rest
directive state the path-mapper-identifier to use, and pass the current variables in to the function, maybe?
from apollo-link-rest.
Cool, yes that would cover my use case at least π
from apollo-link-rest.
@HeyHugo -- I recommend opening a new GitHub issue to track that feature idea. If you have time & the inclination to help improve apollo-link-rest
if you wanted to implement this, I could help you get it reviewed. -- Like I said, most of what you'll need to do is like the bodyBuilder
from apollo-link-rest.
Ok, I'll make an attempt at this.
Would be my first TypeScript code ever, so I'm expecting some bumps π¬
from apollo-link-rest.
looks good to me! Thanks for the very fast response and PR π
from apollo-link-rest.
Related Issues (20)
- Fix typo when defining type for bodySerializer on 'bodySerializer' section
- RestLink causes network calls to be executed much later HOT 4
- Is this repo obsolete? HOT 3
- How to batch operations with apollo-link-rest? HOT 4
- Latest possible (0.8.0) release is still in beta with no active changes HOT 5
- TypeError: Cannot read properties of undefined (reading 'selections') HOT 4
- Questions about apollo-link-rest production status HOT 8
- `graphql-anywhere` is unmaintained; how does this impact `apollo-link-rest`? HOT 17
- Use exported variable in POST request body HOT 7
- Can i use DELETE method with request body? HOT 1
- Conditionally skip REST calls HOT 8
- Apollo Link Rest - MockProvider HOT 1
- Apollo return same data even datatype and url is changed through variables HOT 1
- **Urgent**: Lost Maintainer/Collaborator Access HOT 3
- How to limit the number of items of nested array? HOT 2
- Unable to access context value in the graphql query
- Feature Proposal - RestLink chains HOT 1
- Dependency Dashboard
- data and error fields in useQuery hook empty.
- Can only the remaining uncached links be retrieved? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-link-rest.