Giter Club home page Giter Club logo

qix-graphql's Introduction

qix-graphql

GraphQL Server on top of the Qlik Associative Engine (a.k.a. QIX Engine).

NPM version David Codecov CircleCI

Table of Contents

(TOC generated by verb using markdown-toc)

Motivation

qix-graphql provides a GraphQL server sitting on top of the powerful Qlik Associative Engine (a.k.a. QIX Engine), regardless whether it is Qlik Sense Enterprise, a solution build with Qlik Core or Qlik Sense Multi Cloud.

Using GraphQL next to QIX provides a completely new experience how to develop custom solutions:

  • Use the powerful tooling from the GraphQL community, such as GraphiQL.
  • Connect to Qlik environments and Qlik apps in most of the major programming languages, such as C#, Go, Java, JavaScript, Swift, Python, always with the same experience.
  • There is no need anymore to understand Qlik specific constructs such as qHyperCube, SessionObjects, etc., just use GraphQL.
  • Leverage the benefits of a strongly typed system (e.g in IDEs such as Visual Studio Code).

Getting started

Before we connect to various environments (such as Qlik Sense Enterprise, Qlik Core solutions, etc.), let's get started with a simple demo.

Getting the demo up and running

The demo will consist of the following logical components:

  • A QIX Engine (using the the Qlik Core Engine container)
  • A few demo apps mounted to the QIX Engine
  • A GraphQL server connected to the QIX Engine

All services will be spawn up using docker-compose (which requires e.g. Docker for Mac/Windows running on your machine).

As this demo is included in the qix-graphql repo, the easiest way to get started is to clone this repo:

$ git clone https://github.com/stefanwalther/qix-graphql

Then run the following command:

$ QIX_ENGINE_VER=12.171.0 QIX_ACCEPT_EULA=yes docker-compose up -d

Note: QIX_ENGINE_VER and QIX_ACCEPT_EULA are environment variables being used in the docker-compose file.

Explore the GraphQL API using the GraphiQL IDE

Explore the GraphQL server using GraphiQL

We can now open http://localhost:3004/global/graphql in your browser to get the GraphiQL user interface. GraphiQL is a graphical interactive in-browser GraphQL IDE, which allows you to explore the API being provided by qix-graphql, the GraphQL server.

We can also easily get a list of all documents in the IDE:

Note: GraphiQL also provides intellisense, built-in documentation and more, see here for some tipps & tricks for GraphiQL.

In the examples above we have acted on the global scope, which allows us to explore meta-information about different Qlik documents.

Using the URL stated in doc/_links/_docs we can connect to a single document.

Explore the API of a single document, using GraphiQL

If we use (as defined by this demo) http://localhost:3004/doc/:qDocId/graphql we connect to a single document and its API:

Going to the built-in documentation, we'll see the tables of this document we can query:

So let's query one of those tables (in this example the table account on the doc CRM.qvf:

Developing a Client

Creating a client in node.js OK, so far we have seen that we can easily explore the generated APIs on a global and on a doc scope. Now let's create some code so see how we can use the server when developing a custom application using the GraphQL server. It can basically be any kind of an application, a backend-service, a website, a native mobile app; essentially the approach is always the same:
const client = require('graphql-client')({
  url: 'http://localhost:3004/global/graphql'
});

async function getDocs() {
  const query = `{
              docs {
                qDocId
                qDocName
              }
            }`;
  const vars = '';
  return await client.query(query, vars);
}

(async () => {
  let result = await getDocs();
  console.log('Apps in the current environment:\n');
  result.data.docs.forEach(item => {
    console.log(`\t- ${item.qDocName}`);
  });
})();

This will return:

So we don't need to use enigma.js, we don't need to understand specific constructs of the QIX Engine such as qHyperCube, it's basically a very straightforward development experience using common tools.

Features

qix-graphql provides two basic different types of endpoints:

Global Scope:

  • Getting information about one environment (e.g. listing all Qlik docs, etc.)

http(s)://<qix-graphql-host>:<qix-graphql-port>/global/graphql

Doc Scope:

  • Connecting to a single Qlik document to perform operations such as
    • Getting the data from the given document
    • Being able to query the various tables & fields
    • Making selections
    • Creating on demand hypercubes
    • etc.

http(s)://<qix-graphql-host>:<qix-graphql-port>/doc/:qDocId/graphql

Installation

qix-graphql is already packaged as Docker image (stefanwalther/qix-graphql).

$ docker run -d -p 3004:3004 stefanwalther/qix-graphql

Configuration

The following configuration parameters are available:

  • HOST - Host of the GraphQL server, defaults to localhost
  • PORT - Port of the GraphQL server, defaults to 3004
  • QIX_HOST - Host of the QIX Engine, defaults to qix
  • QIX_PORT- Port of the QIX Engine, defaults to 9076

Roadmap

The work has been split into a few iterations:

  • Iteration 1: Core prototyping work <== !!! Sorry to say: WE ARE HERE !!!
    • Focus on core functionality
    • Testing various ideas/concepts
    • No UI work
    • Little documentation
    • Sometimes Messy code ;-)
    • Unstable APIs
  • Iteration 2: Some work on enhanced concepts
    • JWT support / Section Access
    • Using multiple engines, using mira
    • Using in Qlik Sense Multi Cloud
  • Iteration 3: Clean UI & additional functionality

See projects for more details.

Contribution

I am actively looking for people out there, who think that this project is an interesting idea and want to contribute.

Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/stefanwalther/qix-graphql/issues). The process for contributing is outlined below:
  1. Create a fork of the project
  2. Work on whatever bug or feature you wish
  3. Create a pull request (PR)

I cannot guarantee that I will merge all PRs but I will evaluate them all.

Local Development

The easiest way to develop locally is follow these steps:

  1. Clone the GitHub repo
$ git clone https://github.com/stefanwalther/qix-graphql
  1. Install the dependencies
$ npm install
  1. Start the dependencies (Qlik Associative Engine + a few sample apps mounted):
$ make up-deps

Make your code changes, then:

  • Run local tests: npm run test
  • Run local tests with a watcher: npm run test
  • Start the GraphQl server: npm run start
  • Start the GraphQl server with a watcher: npm run start:watch
Running Tests

Having the local dependencies up and running, you can just run the tests by executing:

$ npm run test

If you want to have an watcher active, use:

$ npm run test:watch
CircleCI Tests

To simulate the tests running on CircleCI run the following:

$ make circleci-test

About

Author

Stefan Walther

License

MIT


This file was generated by verb-generate-readme, v0.6.0, on August 12, 2018.

qix-graphql's People

Contributors

renovate-bot avatar renovate[bot] avatar stefanwalther avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

qix-graphql's Issues

Link to doc GraphiQL instance references the wrong host

Describe the bug
When following along with the README, it shows how you can use

_links {
  _doc
}

to get a url to a GraphiQL instance connected to a specific doc. In the README, the example gets hosted locally at localhost:3004. However, the response url that the API provides references qix-graphql instead of localhost as the host. Ex:

{
  "data": {
    "doc": {
      "_links": {
        "_doc": "http://qix-graphql:3004/app/%2Fdocs%2FConsumer%20Goods%20Example.qvf/graphql"
      }
    }
  }
}

To Reproduce
Steps to reproduce the behavior:

  1. Follow the instructions on the README to spin up GraphiQL
  2. Run a query like so to get the link for a doc:
{
  doc(qDocId: "/docs/Consumer Goods Example.qvf") {
    _links {
      _doc
    }
  }
}
  1. Look at the URL that is returned by the API call

Expected behavior
The URL should reference localhost as the host, not qix-graphql.

Examples: Python

The beauty of GraphQL is that it works with many programming languages. Let's provide some examples with the most popular languages.

  • Basic code example
  • Test
  • Integrate test into CircleCI

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Why use Qlik if your using GraphQL

This probably sounds abit random but what extra value does qlik add to a project if your already using GraphQL? GraphQL is basically its own associative engine right? Im just struggling to think why would need Qlik if your already familliar with GraphQL.

Change the basic endpoints

Environment mode:

  • / - Basically just showing HATEOAS links, later on some basic UI
  • /env/graphiql/ - Starting graphiql for the env mode

App mode:

  • /app/:id/graphiql/- GraphiQL for the specifc app

Make the qix-schema dynamic

The qix-schema is now hardcoded, but it actually should be dynamic based on the engine version.
Really not sure how to handle this the best way.

Some basic clean-up & refactoring

Code:

  • Move to async/await
    • ./app-server.js
  • Remove the /docs endpoint
  • Remove/Rename ./modules/app/sample-schema.js
  • health-check
  • Remove package-lock.json
  • Handle all Todo (AAA)
  • Rename modules to match resource thinking / endpoints
  • File ./prototyping-to-be-moved.js

Tests:

  • Simplify tests by moving to async/await
  • Removes logging from tests

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Client examples: node.js

The beauty of GraphQL is that it works with many programming languages. Let's provide some examples with the most popular languages.

  • Basic code example
  • Test
  • Integrate test into CircleCI

CodeCov

  • Use CircleCI to send the code-coverage results to CodeCov.

Installation / Usage instructions do not work

Attempting to follow the installation and usage instructions on the README to get started, docker-compose up fails because the compose file relies on an environment variable QIX_ENGINE_VER:latest:

from docker-compose.yml:

qix:
    container_name: qix
    image: "qlikcore/engine:${QIX_ENGINE_VER:latest}"
    command: [
      "-S", "DocumentDirectory=/docs",
      "-S", "AcceptEULA=yes"
    ]

Client examples: c#

The beauty of GraphQL is that it works with many programming languages. Let's provide some examples with the most popular languages.

  • Basic code example
  • Test
  • Integrate test into CircleCI

Client examples: go

The beauty of GraphQL is that it works with many programming languages. Let's provide some examples with the most popular languages.

  • Basic code example
  • Test
  • Integrate test into CircleCI

CircleCI

  • Basic CircleCI integration for both unit and integration tests

Data type conversion

Currently the different data types are not handled properly, this needs to be fixed and tested.

Experiment with stateful vs stateless

It would be interesting to run the GraphQL server in two different modes (based on configuration):

  • Stateful
    • ws connection remains open
    • user can make selections
    • can get current selections
    • can execute a chain of commands
    • etc.
  • Stateless
    • always opening, closing, re-opening the ws-connection
    • do not allow the user to make selections
    • some mutations and queries should then just not be available
    • Basically the GraphQL server acts then like a connector to fetch data easily from a Qlik app

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Ability to run this API against any Core instance?

Currently, it appears that when you use this package, it spins up its own Core instance and hooks into that to give you access to GraphQL queries for that specific instance. Is there a way to leverage that GraphQL query layer with any Core instance? That would be much more desirable to me. For example, I've got several Core containers running on my machine related to various projects. I'd love to leverage the GraphQL query layer as an independent service that I can use with any of those instances as needed.

Basic Documentation

  • Motivation
  • Background information / Key concepts
    • What is GraphQL
    • GraphQL Community / eco-system / programming languages
    • GraphiQL
  • Examples
    • node.js
    • go
    • Python
    • C#
  • How to set up
    • A demo environment
    • Dependencies
    • Run tests
    • Watchers

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.