How would one pass variables into a graphql query?
# meltano-plugin-development
a
How would one pass variables into a graphql query?
I'm trying to understand the internals of GraphQLStream but maybe there is a simpler way
e
Hi Adam. What type of variables do you need to pass to the query?
a
Hi Edgar. I'm referring to the query variables for a gql query. In postman they look like this:
I think I just figured it out
Copy code
def get_url_params(self, context, next_page_token):
        params = {
            'organizationId': self.config.get("organization_id"),
            'startDate': self.config.get("start_date")
        }
        return params
Previously I was using urlencode for the params, which I think is intended for REST streams
e
Ah yeah, it's a bit obscure but those are passed as
variables
to the payload: https://github.com/meltano/sdk/blob/bfb7baaaa5743d09e37c79c714c905e716a65283/singer_sdk/streams/graphql.py#L79-L82
a
Closing this out--what Edgar pointed out and I tried worked great