-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add hasura client and remove sequelize #2
Comments
Hi @rubenabix, You want to use https://www.npmjs.com/package/graphql-request to take advantage of the powerful queries and mutations that hasura generate out the box to handle custom business logic? |
@xavier506 @rubenabix I have a few concerns about to use graphql-request, let me explain it It will work fine if the project allow us to keep all mutations and queries open to the logged user, but there are some cases where we can't have the query or mutation open, for example if the app have a shopping cart we cant allow to the user create a record in the Also I feel that graphql-request project its a little abandoned there are about 42 open issues and 40 open PR and the last commit in master branch its from Sep 21, 2018, besides the package its part of prisma-labs/graphcool other graphql engine |
@adriexnet Maybe we can use only backend flag graphql-request function is very basic: a POST, so we can use other client perhaps |
@rubenabix but "Setting backend-only is currently available for insert mutations only." so we still have the problem with update actions |
@kecoco16 What do you think? |
@adriexnet @rubenabix @xavier506 to use any mutation or query without restrictions we can connect to the Hasura client using the admin secret key, so when we want to use a query or mutation with Hasura access control we can connect by passing the authorization header and when we don't want access control we can connect using the admin secret key e.g. Whit access control: we can only use the mutations or querys exposed to the specific user role const hasuraClient = new GraphQLClient(hasuraConfig.url, {
headers: {
Authorization: authorization
}
}) Whitout access control: we can use any query or mutation we want const hasuraClient: new GraphQLClient(hasuraConfig.url, {
headers: {
'x-hasura-admin-secret': hasuraConfig.adminSecret
}
}) And as Ruben says graphql-request is just a http client so we can use fetch if we want but whit graphql-request is a little more prettier. This is the reason why we don't need an ORM we can do whatever we want through Hasura without writing extra code and without maintaining external libraries like sequelize. |
@kecoco16 Thanks for the explanation, if that works for the case that I exposed before and you and @rubenabix agree that graphql-request it's the best approach it will be, I trust you 👍 |
Example
The text was updated successfully, but these errors were encountered: