Giter Club home page Giter Club logo

ksqldb-graphql's Introduction

ℹī¸ This project is a proof of concept

ksqldb-graphql

GraphQL integration for ksqlDB to facilitate easier app creation by abstracting ksqlDB syntax and protocol.

Background

KLIP-15 creates a new API with which to interact. This repository contains packages to generate graphQL as well as handle the ksqlDB protocol.

Installation

yarn add @confluentinc/ksqldb-graphql

Integration

For statements to be executed against ksqDB, RequestOptions must be provided, both at startup and in the context of the graphQL resolvers.

The prebuild step, generateGraphQL, returns a promise and should be called prior to starting a graphQL server.

Usage

import { connect } from 'http2';
import { ApolloServer } from 'apollo-server';
import { generateGraphQL } from '@confluentinc/ksqldb-graphql';
import { addResolveFunctionsToSchema } from 'graphql-tools';

const session = connect(`http://localhost:8088`);
const options = {
  hostname: 'localhost',
  port: 8088,
};

generateGraphQL({ options }).then(
  ({ schemas, queryResolvers, subscriptionResolvers, mutationResolvers }) => {
    const server = new ApolloServer({
      context: async () => ({
        ksqlDB: {
          options,
          session,
        },
      }),
      schema: addResolveFunctionsToSchema({
        schema: schemas,
        resolvers: {
          Subscription: subscriptionResolvers,
          Query: queryResolvers,
          Mutation: mutationResolvers,
        }
      }),
      subscriptions: {
        keepAlive: 1000,
      },
    });
    server.listen();
  }
);

Packages

@confluentinc/ksqldb-graphql

Generates the schema and resolvers based on an existing ksqlDB cluster.

@confluentinc/ksqldb-client

Resolves the ksqlDB protocol and executes ksqlDB statements

ksqldb-graphql's People

Contributors

colinhicks avatar confluentjenkins avatar dependabot[bot] avatar eccentricexit avatar elismaga avatar jkao97 avatar jrea avatar lyoung-confluent avatar renovate-bot avatar

Stargazers

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

Watchers

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

ksqldb-graphql's Issues

Make sure it works with references.

I have a demo setup where I use references, but it fails to configure the schema, likely because the same reference is used multiple times.
This is the error I get

Could not generate schemas: Schema must contain uniquely named types but contains multiple types named "ADDRESS".
(node:27) UnhandledPromiseRejectionWarning: Error: Error: Unable to create schemas and resolvers
    at /root/app/dist/node_modules/@confluentinc/ksqldb-graphql/src/schema.js:201:27
    at Generator.next (<anonymous>)
    at fulfilled (/root/app/dist/node_modules/@confluentinc/ksqldb-graphql/src/schema.js:5:58)

Demo can be found at https://github.com/gklijs/ksqlDB-GraphQL-poc you probably need to restart the js-graphql-endpoint container to see the error.

Is this project dead?

Graphql and kafka is something we really want to be using with a library such as this. Is this still actively being maintained/developed?

Publish transpiled npm packages

At the moment the @confluentinc/ksqldb-graphql and @confluentinc/ksqldb-client packages are pushed to npm as TypeScript. This makes it very hard to use the packages. Basically, the only solution is to add TypeScript to the project, and to then set it to transpile the module from node_modules.

The reasons it works in the rideshare demo are that the packages are used through yarn workspaces locally, and that rideshare itself is written in TypeScript.

Instead, I would expect the npm package to contain the JavaScript version, while it could still export the TypeScript types.

This seems like a good article explaining how to do it: https://medium.com/cameron-nokes/the-30-second-guide-to-publishing-a-typescript-package-to-npm-89d93ff7bccd

"This endpoint is only available when using HTTP2"

I'm trying to launch the RIDESHARE project with my own ksqldb server, but I'm running through this error whenever I try to test a query through the playground on the server side
** {"error":
{"name": "Error",
"message": "This endpoint is only available when using HTTP2"}
}**
Also on the client side, I can't see the cars while getting this error
client. t's: 545 WebSocket connection to 'ws://ec2-54-187-136-198.us-west-2.compute.amazonaws.com:3010/graphql' failed: Error in connection establishment: net:: ERR_CONNECTION_REFUSED .
I should mention that all the data gets saved in the Ksqldb server

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.