question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[GraphQL] Updates to Stored Procedure support for Engine

See original GitHub issue

Summary

Add a new execute permission to make it easier to publish stored procedures

Motivation

Supporting Stored Procedure execution via methods other than POST for REST and Queries for GraphQL creates some confusion on how permissions are defined and also it leads to a potential break of best practices regarding the idempotency of non-POST methods.

Functional Specification

To best support Stored Procedure in Data API Builder, we may want to introduce a new action, named execute that

  • can be used only if the published object is a stored procedure
  • must be the only action defined in a role
  • REST: will be mapped to the POST method by default
  • GraphQL: will generate a Mutation by default

Users will be able to decide if they want to use another method other than POST and generating a Query instead of a Mutation by defining their preference using the rest or graphql objects that are optionally available withing the entity object. For example:

"GetCowrittenBooksByAuthor": {      
  "source": {
	"type": "stored-procedure",
	"object": "dbo.stp_get_all_cowritten_books_by_author",
	"parameters": {
	  "author": "?",
	  "searchType": "c"
	}
  }, 
  "graphql":{
	"operation": "mutation" 
  },
  "rest": {
	"method": ["GET"]
  },           
  "permissions": [
	{
	  "role": "anonymous",
	  "actions": [ "execute" ]
	}
  ]
}

With this approach we can provide developers the best behaviour by default, but let them decide what is best for them if they need to depart from the best practices for any reasons.

References

[GraphQL] Stored Procedure support for Engine [REST] Update/Create is breaking with Single Permission Support stored procedure Behavior of Update Action for Stored-Procedures in CLI

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
Aniruddh25commented, Jan 13, 2023
"rest": {
	"method": "GET"
  }
"

Shouldn’t method here be an array? To enable multiple methods for the same stored procedure if the developer so chooses?

2reactions
Aniruddh25commented, Jan 13, 2023

Do we want to have the following restrictions for the operations defined for an Stored Procedures REST/GraphQL operations?

Key:

  • Columns = GraphQL
  • Rows = REST

Query Mutation GET X POST X PUT X PATCH X DELETE X e.g. If GraphQL operation is mutation, REST operation cannot be GET.

If the developer is explicitly configuring REST method to be GET, and specifies nothing for GraphQL, they will end up in a situation where default is picked for GraphQL which is mutation. If we restrict this, the developer has to modify the config file, to override the default operation for GraphQL to be query, which seems additional overhead if I am only using REST. I dont think we should restrict if they configure incompatible REST/GraphQL operations - the fact that they override the defaults means they understand what they are doing so we rely on what they have specified.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Server stored procedures with Hasura GraphQL Engine
Explore the benefits of adding support for SQL Server stored procedures to the Hasura GraphQL Engine, along with some compelling use cases.
Read more >
SQL Server: Stored Procedures - hasura/graphql-engine
Track stored procedures saved in your database and expose and enable them as types in the Hasura GraphQL schema. User value / outcome....
Read more >
[sql-server] Support stored procedures and functions on ...
Hi, any update on when this feature (DB procedures and functions) will be available?
Read more >
Execute Stored Procedures to GraphQL in BizTalk
Stored procedures implement GraphQL actions that cannot be represented as SELECT, INSERT, UPDATE, and DELETE statements. This article shows how to generate ...
Read more >
What's New in Data API builder
Wildcard Operation Support for Stored Procedures in Engine and CLI. Version 0.5.32. A summary of the most relevant changes done in this version ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found