0.1.0 • Published 3 years ago

@onichandame/type-graphql-tag v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Type Graphql Tag

Example Usage

import {Field,Type,createSchema} from '@onichandame/type-graphql-tag'

class User {
  @Field()
  name!:string
}

@Type(`PostComment`)
class Comment{
  @Field()
  text!:string
}

class Post {
@Field()
author!:User
  @Field({[Comment]})
  comments!:Comment[]
}

class PostAddCommentsInput{
  @Field({type:()=>[Comment]})
  comments: Comment[]
}

const schema=createSchema({operation:`mutation`,endpoint:`addComments`,output:Post,input:PostAddCommentsInput})
/* Same as below
const schema = gql`
  mutation ($comments: [PostCommentInput]){
    addComments (comments: $comments){
      author {
        name
        comments {
          text
        }
      }
    }
  }
`
*/