Apollo-link-rest: Struggles with path params

Created on 18 Jun 2018  路  4Comments  路  Source: apollographql/apollo-link-rest

I am tried to pass params to params argument like this:

query{
    tumblrPosts @rest(type: "TumblrPosts", path: "/posts", params: {api_key: $api_key, tag: $tag}) {
        response {
            posts {
                title,
                summary,
                body,
                type,
                post_url,
                tags
            }
        }
    }
}

But it did not work at all. Params did not pass to the request. The last variant works, but it looks not so nice:

query{
    tumblrPosts(api_key: $api_key, tag: $tag) @rest(type: "TumblrPosts", path: "/posts?api_key=:api_key&tag=:tag") {
        response {
            posts {
                title,
                summary,
                body,
                type,
                post_url,
                tags
            }
        }
    }
}
bug 馃悰 enhancement馃挕

All 4 comments

Based on the example in the docs... pretty sure you need to define it as:

query GetTumblrPosts($api_key: String!, $tag: String!) {
...

Hello @i-hun, your code example indeed is suggested by some of our docs. Unfortunately, we didn鈥檛 exactly get around to building that feature.

@fc鈥檚 advice is exactly how the system works today. You can merge both your examples:

query GetTumblrPosts($api_key: String!, $tag: String!) {
   tumblrPosts(api_key: $api_key, tag: $tag) @rest(type: "TumblrPosts", path: "/posts?api_key=:api_key&tag=:tag") {
        response {
            posts {
                title,
                summary,
                body,
                type,
                post_url,
                tags
            }
        }
    }
}

To both of you or anyone reading this, I鈥檇 love to get this fixed, as currently our API can鈥檛 unpack input types.

I haven鈥檛 had any time recently to investigate how to implement unpacking. (Via params or other syntaxes that I鈥檇 be happy to document on request)

I think this should be fixed or may just be outdated since we now use the new param syntax.

Was this page helpful?
0 / 5 - 0 ratings