This project is archived. Its data is read-only. This project is read-only.
GraphQLStream doesn't support variables in query
I made my first tap with the SDK today, and it was so painless, only took a few hours. Thanks y'all! I built a tap for NewRelic which uses their GraphQL API. I'm new to GraphQL but I'm pretty sure I'm using it correctly here. I want to be able to use the query variables to inject parameters into this query as opposed to doing string replacements in python: ```graphql query ($accountId: Int!, $query: Nrql!) { actor { account(id: $accountId) { nrql(query: $query) { results } } } } ``` The problem is [GraphQLStream wraps `self.query` in `query { ... }`](https://gitlab.com/meltano/singer-sdk/-/blob/main/singer_sdk/streams/graphql.py#L26) so we can't write the GraphQL to accept arguments. As a workaround, I just overrode the method and replaced it with the whole query: ```python def prepare_request_payload( self, partition: Optional[dict], next_page_token: Optional[DateTimeType] = None ) -> Optional[dict]: res = super().prepare_request_payload(partition, next_page_token) res["query"] = self.query return res ``` Also somewhat related, the cookiecutter template generates code suggesting `self.graphql_query` but `GraphQLStream` expects it to be called `self.query`.
issue