0.0.72 • Published 6 years ago

@cortexql/ts2graphql v0.0.72

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
6 years ago

CortexQL GraphQL Transpiler

A runtime tranpiler and generator that converts your TypeScript code into GraphQL types

Key aspects

  • It doesn't use decorators to transpile code
  • It inflicts a folder/file export pattern
  • Depends on TypeDoc JSON generator

How to use it

Set your enviroment to have the following directories

./types

Include all GraphQL types in separated files that export the TypeScript type.

Interface

Interface TypeScript types are converted to GraphQL Input Object Type

input
// types/Login.ts
/**
 * Login input
 */
export interface Login {
  /**
   * The user's email address
   */
  email: string;
  /**
   * The user's plain password
   */
  password: string;
}
output
// schema/Login.graphql
# Login input
input Login {
  # The user's email address
  email: String!
  # The user's plain password
  password: String!
}

Class

Class TypeScript types are converted to GraphQL Object Type

// types/User.ts
import { Post } from './Post';

/**
 * User object
 */
export class User {
  /**
   * The user's unique id
   */
  id: string;
  /**
   * The user's email address
   */
  email: string;
  /**
   * The user's plain password
   * @GraphQL.disable
   */
  password: string;
  /**
   * Get latest user's posts
   */
  async getLatestPosts(
    args: {
      /**
       * The maximum number of posts to fetch
       */
      limit?: number = 10
    },
    context: any
  ): Promise<Post[]> {
    // ...
  }
  /**
   * Check user password
   * @GraphQL.disable
   */
  checkPassword(password: string): boolean {
    // ...
  }
}
output
// schema/User.graphql
# User object
type User {
  # The user's unique id
  id: String!
  # The user's email address
  email: String!
  # Get latest user's posts
  getLatestPosts(
    # The maximum number of posts to fetch
    limit: Float = 10
  ): [Post]
}

It comes with a CLI

ts2graphql -p src -o build/graphql

TODO: More examples and tutorials

0.0.72

6 years ago

0.0.71

6 years ago

0.0.70

6 years ago

0.0.69

6 years ago

0.0.68

6 years ago

0.0.67

6 years ago

0.0.66

6 years ago

0.0.65

6 years ago

0.0.64

6 years ago

0.0.63

6 years ago

0.0.62

6 years ago

0.0.61

6 years ago

0.0.60

6 years ago

0.0.59

6 years ago

0.0.58

6 years ago

0.0.57

6 years ago

0.0.56

6 years ago

0.0.55

6 years ago

0.0.54

6 years ago

0.0.53

6 years ago

0.0.52

6 years ago

0.0.51

6 years ago

0.0.50

6 years ago

0.0.49

6 years ago

0.0.48

6 years ago

0.0.47

6 years ago

0.0.46

6 years ago

0.0.45

6 years ago

0.0.43

6 years ago

0.0.42

6 years ago

0.0.41

6 years ago

0.0.37

6 years ago

0.0.36

6 years ago

0.0.35

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.32

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.2

6 years ago