Skip to content

Conversation

@abhishekkumams
Copy link
Contributor

@abhishekkumams abhishekkumams commented Nov 14, 2022

Why make this change?

What is this change?

  • Updating GraphQLSchemaGenerator to support creation of StoredProcedures Schema.
  • Updated the MsSqlCommands to add some new stored procedure, one for each type of CRUD operations.
  • Using the ColumnDefinition in SourceDefintion class to store stored-procedure result set definition.
  • Created a new class GraphQLStoredProcedureBuilder, which helps in generating stored procedure schema by building arguments from parameters and result set
  • StoredProcedures only supports one CRUD action as of now.
  • StoredProcedure with Read action goes to Query, while other CRUD actions makes it mutation operation on graphQL.
  • QueryBuilder: it checks if the object type is StoredProcedure, generates the query with Same name
  • MutationBuilder works similarly, it just checks if it has any of the action except READ, and adds it to mutation fields.
  • Currently we only support simple Stored-Procedure,i.e. stored procedure that requires only 1 CRUD action to execute.
  • If the stored-procedure having create permission is also trying to READ, results won't be displayed, but execution of stored procedure will still happen
  • Wrote validation to check all the parameters are provided in the config that are in db. (will update it to not be mandatory once we figure out an efficient way to find default values).
  • We also do a check the runtime config for stored-procedure to have exactly 1 CRUD action.
  • Updated MsSQLbooks.sql as well to have the new stored-procedures
  • Did some code refining
  • For complete design doc, refer: updating stored-procedure design doc #896

To Be Addressed in Separate PR (issue: #989 ):

  1. To fetch parameters information from DB, like parameter type, their default value.
  2. parameter type for correct parsing of the value
  3. default parameter value so that if not provided in the config, we still generate the correct graphQL schema

How was this tested?

  • unit tests
  • Integration Tests

Sample Request(s)

Insert (Mutation)

image

Count (Query)

image

Update(Mutation)

image

Delete(Mutation)

image

Select (Query)

image

Copy link
Contributor

@ayush3797 ayush3797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @abhishekkumams for addressing all the review comments promptly. Great work! LGTM!

Copy link
Contributor

@severussundar severussundar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@abhishekkumams abhishekkumams merged commit 1e60523 into main Nov 29, 2022
@abhishekkumams abhishekkumams deleted the dev/abhishekkuma/add-graphql-support-for-stored-procedure branch November 29, 2022 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine issues that require change in engine code enhancement New feature or request graphql

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[GraphQL] Stored Procedure support for Engine

5 participants