0.0.72 • Published 7 years ago

@cortexql/ts2graphql v0.0.72

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
7 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

7 years ago

0.0.71

7 years ago

0.0.70

7 years ago

0.0.69

7 years ago

0.0.68

7 years ago

0.0.67

7 years ago

0.0.66

7 years ago

0.0.65

7 years ago

0.0.64

7 years ago

0.0.63

7 years ago

0.0.62

7 years ago

0.0.61

7 years ago

0.0.60

7 years ago

0.0.59

7 years ago

0.0.58

7 years ago

0.0.57

7 years ago

0.0.56

7 years ago

0.0.55

7 years ago

0.0.54

7 years ago

0.0.53

7 years ago

0.0.52

7 years ago

0.0.51

7 years ago

0.0.50

7 years ago

0.0.49

7 years ago

0.0.48

7 years ago

0.0.47

7 years ago

0.0.46

7 years ago

0.0.45

7 years ago

0.0.43

7 years ago

0.0.42

7 years ago

0.0.41

7 years ago

0.0.37

7 years ago

0.0.36

7 years ago

0.0.35

7 years ago

0.0.34

7 years ago

0.0.33

7 years ago

0.0.32

7 years ago

0.0.31

7 years ago

0.0.30

7 years ago

0.0.29

7 years ago

0.0.27

7 years ago

0.0.26

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.2

7 years ago