Skip to content
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

Provides GraphQL support over Publisher REST API [Do not merge] #5967

Closed

Conversation

wasuradananjith
Copy link
Contributor

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

  • Provides functionality to create a GraphQL API through Publisher REST API
  • Provides the functionality to add a GraphQL schema for a particular API using our Publisher REST API
  • Provides the functionality to retrieve a GraphQL schema of a particular API using our Publisher REST API

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

  • Using Publisher APIs in WSO2 someone can
    • Create a GraphQL API
    • Upload a Schema definition for an existing GraphQL API
    • Retrieve a Schema definition of an existing GraphQL API

Documentation

Documentation changes are required.

Automation tests

  • Unit tests
    Added few tests in
    • components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerTestCase.java
    • components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/UserAwareAPIProviderTest.java

Test environment

  • jdk1.8.0_144
  • Ubuntu 16.04 LTS

@tharikaGitHub tharikaGitHub added the Docs/Has Impact Has an impact on the WSO2 Documentation label Feb 5, 2019
@bhathiya
Copy link
Contributor

bhathiya commented Feb 8, 2019

Why shouldn't we merge this? What's pending?

@harsha89
Copy link
Member

harsha89 commented Jul 2, 2019

Closing this as it's not needed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs/Has Impact Has an impact on the WSO2 Documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants