Coder Social home page Coder Social logo

ofbiz-graphql's Introduction

Apache OFBiz® GraphQL plug-in

100
100

This plug-in a GraphQL plugin that lets OFBiz to define GraphQL API.

What’s included

OFBiz GraphQL API based on graphql-java suite of libraries

The plug-in uses the following dependencies
  • com.graphql-java:graphql-java:13.0

  • com.graphql-java-kickstart:graphql-java-servlet:9.0.1

  • com.graphql-java-kickstart:graphql-java-tools:5.7.1

  • io.github.graphql-java:graphql-java-annotations:7.2.1

The endpoint is configured by subclassing SimpleGraphQLHttpServlet from graphql-java-servlet dependency.

public class GraphQLEndpointServletImpl extends SimpleGraphQLHttpServlet {

Usage

It comes with a demo query operation outlined below. The schema part is something that needs to be refined further. Both ways of creating the schema viz. GraphQL SDL and Programmatically using Java API, are demonstrated. This part will be further enhanced to include other operations that can be defined easily.

Queries can be executed like below:

'/graphql/?query={graphQLQueryString}' or '/graphql/?query={graphQLQueryString}&&variables={graphQLVariables}&&operationName={operationName}'

The bundled up schema does not define any mutation, but executing mutations is supported via POST only as per GraphQL specifications.

Demo Query operation

The schema defines a single Query type operation to fetch product details with product id passed as parameter: Input:

{
  product(id : "WG-9943-B3")
  {
    productId
    productName
    isVirtual
    primaryProductCategoryId
    productTypeId
  }
}

Output:

{
  "data": {
    "product": {
      "productId": "WG-9943-B3",
      "productName": "Giant Widget B3",
      "isVirtual": "N",
      "primaryProductCategoryId": "202",
      "productTypeId": "FINISHED_GOOD"
    }
  }
}

Authentication

The GraphQL endpoint is secured. Authentication scheme is "Bearer <JWT>". Every query/muation/subscription operation must have an Authorization header associated with it. Example Request:

GET /graphql/graphql/?query={
  product(id : "WG-9943-B3")
  {
    productId
    productName
    isVirtual
    primaryProductCategoryId
    productTypeId
    ddd
  }
} HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJBcGFjaGVPRkJpeiIsImlhdCI6MTU0NzczOTM0OCwiZXhwIjoxNjc5Mjc1MzQ4LCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiR2l2ZW5OYW1lIjoiSm9obm55IiwiU3VybmFtZSI6IlJvY2tldCIsIkVtYWlsIjoianJvY2tldEBleGFtcGxlLmNvbSIsInVzZXJMb2dpbklkIjoiYWRtaW4iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.fwafgrgpodBJcXxNTQdZknKeWKb3sDOsQrcR2vcRw97FznD6mkE79p10Tu7cqpUx7LiXuROUAnXEgqDice-BSg

ofbiz-graphql's People

Contributors

girishvasmatkar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.