Hasura - Use custom headers in queries and mutations - graphql

I would like to be able to use custom headers in queries and mutations.
Basically it would be some context that all the queries and mutations should take into account.
I cannot find a way to do it. Is it even possible with the the current (v2.15.0 as of writing) version of Hasura?
Tried searching the web

Related

How to use Redux toolkit with Graphql query type subscriptions

I like the query types in Graphql, but I still need to control the local state. I am most comfortable doing this in Redux toolkit, in the future I will need subscriptions query.
From the information I have found here https://redux-toolkit.js.org/rtk-query/usage/customizing-queries but will it work with subscriptions request.
Is it possible to implement all this in next.js?

How do I prevent deleted records from appearing in my AWS Amplify GraphQL results?

By default the Amplify GraphQL APIs return deleted items.
Worse, as near as I can tell there is apparently no way to filter them: Neither syncXYZTable nor listXYZTable queries accept the _deleted field as a parameter. Fortunately the generated code in the DataStore SDK filters out these items, and (somewhat confusingly) the Amplify Studio does not display them (in the Contents tab); but this only highlights the inconsistency: For example as a developer I don't see deleted items anywhere, but as a data scientist or manager using the GraphQL API, I have (it seems) no way of avoiding them.
Am I missing something. Is there really no way to filter out deleted items using the Amplify GraphQL API?
I had to filter these _deleted records in the code. Did not find a way to filter out in GraphQL Response

Mutation to create a GIST

I want to create a gist using GitHub's GraphQL API. Although, I couldn't find the mutation to use.
I tried searching for a mutation in the docs but there was none matching addGist.
Is there still a way to make a POST request to create a gist using GraphQL or will I need to resort to using many GitHub's API endpoints?

Mutations to trigger a promise

I'm trying to figure out how I might be able to adopt Apollo in my React Native project compared to RXJS & Redux.
One of the special things about this app is that data mutations are not done through a traditional API but through Blockchain based transactions. Therefore I cannot simply call mutate in Apollo and expect it to eventually mutate something on the database as it's gonna go to a completely different several using a completely different library.
Would it be possible to have some kind of middleware which intercepted a mutation request and redirected it to another async library to get the job done? I'm wondering if apollo-link might be the way to do it.

GraphQL Viewer for mutations

Is it a good practice to have a viewer for GraphQL mutations? Theoretically this makes sense to me as some mutation end points shouldn't be possible if you are not logged in, etc.
But when I see examples on the web, I only see implementation of GraphQL viewers for queries. For mutations, I do not see any implementation of viewers. For example, the GitHub API doesn't have a viewer on top of all their mutations.
The viewer field isn't a good practice, either for mutations or queries. It's a remnant of Facebook's legacy GraphQL platform from before it was open-sourced, which didn't allow arguments on root query fields. This meant that all of the fields needed to be moved one level down, below viewer.
The current way to do auth in GraphQL, at least in the JavaScript implementation, is by getting the user data based on something like an HTTP header and putting it on context, as mentioned here: http://graphql.org/learn/authorization/
Therefore, there is no reason to do viewer for mutations, or for queries. Most GraphQL clients don't mind, but one situation where it could make sense to have it in queries specifically is if you are using Relay 0.x, which has inherited some of Facebook's legacy GraphQL limitations. Hopefully a future version of Relay will remove this requirement.
For an additional source, read this comment from Lee Byron, one of the original creators of GraphQL.

Resources