1.3.0 • Published 1 year ago

@kult/graphql v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@kult/graphql

Status GitHub Issues GitHub Pull Requests License

Graphql plugin for @kult/core

Have a look at our docs for more information.

Installation

yarn:

yarn add @kult/graphql

NPM:

npm i @kult/graphql

Usage

Create a schema.graphql in your src directory:

type Query {
  hello: String
}

type Mutation {
  sayHello: String
}

Register the plugin in ./src/app/config/plugins.ts

import KultGraphqlPlugin from '@kult/graphql';

export default {
  plugins: [KultGraphqlPlugin],
};

Define your queries and mutations using the @Query and @Mutation decorators:

import { Application, ControllerBase, Controller } from '@kult/core';
import { Mutation, Query } from '@kult/graphql';

@Controller('/users')
class UserController extends ControllerBase {
  constructor(app: Application) {
    super(app);
  }

  @Query()
  hello() {
    return 'hello world';
  }

  @Mutation()
  sayHello() {
    return 'hello world';
  }
}

export default UserController;

Environment Variables

Ensure this port is different than your server's port

GRAPHQL_PORT=3001

Community

Authors

See also the list of contributors who participated in this project.