Skip to content
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

Struggles with path params #125

Closed
i-Hun opened this issue Jun 18, 2018 · 5 comments
Closed

Struggles with path params #125

i-Hun opened this issue Jun 18, 2018 · 5 comments

Comments

@i-Hun
Copy link

i-Hun commented Jun 18, 2018

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
            }
        }
    }
}
@fc
Copy link

fc commented Jun 19, 2018

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

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

@fbartho
Copy link
Collaborator

fbartho commented Jun 19, 2018

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

@fc’s 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’d love to get this fixed, as currently our API can’t unpack input types.

@fbartho
Copy link
Collaborator

fbartho commented Jun 19, 2018

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

@fbartho fbartho changed the title params argument don't working Feature Request: Input Type Unpacking Jul 6, 2018
@fbartho fbartho changed the title Feature Request: Input Type Unpacking Feature Request: Input Type Unpacking for Path Parameters Jul 6, 2018
@fbartho fbartho changed the title Feature Request: Input Type Unpacking for Path Parameters Struggles with path params Jul 6, 2018
@paulpdaniels
Copy link
Contributor

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

@fbartho
Copy link
Collaborator

fbartho commented Jan 5, 2022

Closing for now

@fbartho fbartho closed this as completed Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants