Provides GraphQL support over Publisher REST API [Do not merge] #5967
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
We can create a GraphQL API by simply using our Publisher REST API, but we cannot do it since we need to have GRAPHQL as a type in our publisher definition. After that change is done we can proceed and create a GraphQL API.
A GraphQL API mainly defined based on a schema file which consists of all the required definitions of queries and mutations which can be used to invoke the particular GraphQL API. So there is a need to handle this schema file through Publisher REST API.
Goals
Approach
GraphQL is developed by Facebook which is an alternative to REST. It is a query language for APIs where a particular user can specify exactly what data is needed from an API. We know that we can use a Swagger Definition (Open API Specification) to design a REST API. But in GraphQL, we can use Schema Definition Language (SDL) to write the Schema for a GraphQL API. Invoking a GraphQL API simply means fetching data using GraphQL queries and writing data using GraphQL mutations.
We can simply create and publish a GraphQL API using the Publisher REST API which we have in WSO2 API Manager. You just need to change the type of the API as GRAPHQL instead of HTTP/WS/SOAPTOREST and change the apiDefinition as follows (following is the required defintion for a GraphQL API).
"{"swagger": "2.0","info": {"title": "","version": ""},"paths": {"/": {"get": {"responses": {"200": {"description": ""}},"parameters": [{"name": "query","in": "query","required": true,"type": "string","description": " Query to be passed to the GraphQL API"}],"produces": ["application/json"],"consumes": ["application/json"],"summary": "GET method to be used in GraphQL API"},"post": {"parameters": [{"name": "Payload","description": "Query or Mutation to be passed to the GraphQL API","required": false,"in": "body","schema": {"type": "object","properties": {"payload": {"type": "string"}}}}],"responses": {"200": {"description": ""}},"summary": "POST method to be used in GraphQL API","produces": ["application/json"],"consumes": ["application/json"]}}}}"
In we have given support from WSO2 APIM in order to create and publish a GraphQL API in order to invoke it over https/http.
Please refer the mail thread subjected as "[Architecture] GraphQL support for WSO2 APIM" and the Git issue in wso2/product-apim#3184 for more information.
User stories
Documentation
Documentation changes are required.
Automation tests
Added few tests in
Test environment