All Projects → graphql-editor → transform-graphql

graphql-editor / transform-graphql

Licence: MIT license
⚙️ Transformer function to transform GraphQL Directives. Create model CRUD directive for example

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to transform-graphql

Bentools Etl
PHP ETL (Extract / Transform / Load) library with SOLID principles + almost no dependency.
Stars: ✭ 45 (+95.65%)
Mutual labels:  transformer, transform
Typescript Transform Macros
Typescript Transform Macros
Stars: ✭ 85 (+269.57%)
Mutual labels:  transformer, transform
Ngx Dynamic Form Builder
FormBuilder + class-transformer + class-validator = dynamic form group builder for Angular10+
Stars: ✭ 93 (+304.35%)
Mutual labels:  transformer, transform
zero
Zero -- A neural machine translation system
Stars: ✭ 121 (+426.09%)
Mutual labels:  transformer
verseagility
Ramp up your custom natural language processing (NLP) task, allowing you to bring your own data, use your preferred frameworks and bring models into production.
Stars: ✭ 23 (+0%)
Mutual labels:  transformer
graph-transformer-pytorch
Implementation of Graph Transformer in Pytorch, for potential use in replicating Alphafold2
Stars: ✭ 81 (+252.17%)
Mutual labels:  transformer
batch-transforms
Batch equivalent of PyTorch Transforms.
Stars: ✭ 33 (+43.48%)
Mutual labels:  transform
ts-transform-react-jsx-source
TypeScript AST Transformer that adds source file and line number to JSX elements
Stars: ✭ 12 (-47.83%)
Mutual labels:  transform
transformer
A PyTorch Implementation of "Attention Is All You Need"
Stars: ✭ 28 (+21.74%)
Mutual labels:  transformer
cometa
Corpus of Online Medical EnTities: the cometA corpus
Stars: ✭ 31 (+34.78%)
Mutual labels:  transformer
pytorch-gpt-x
Implementation of autoregressive language model using improved Transformer and DeepSpeed pipeline parallelism.
Stars: ✭ 21 (-8.7%)
Mutual labels:  transformer
amplify-material-ui
A Material-UI based implementation of aws amplify
Stars: ✭ 32 (+39.13%)
Mutual labels:  amplify
OpenPrompt
An Open-Source Framework for Prompt-Learning.
Stars: ✭ 1,769 (+7591.3%)
Mutual labels:  transformer
transformer-tensorflow2.0
transformer in tensorflow 2.0
Stars: ✭ 53 (+130.43%)
Mutual labels:  transformer
dgraph-orm
Simplified schema creation, queries and mutations for Dgraph.
Stars: ✭ 47 (+104.35%)
Mutual labels:  dgraph
ImageTrans
一个仿微信的图片查看过渡动画demo 支持拖动图片手势返回 ,缩略图与原图无缝切换
Stars: ✭ 42 (+82.61%)
Mutual labels:  transform
BossNAS
(ICCV 2021) BossNAS: Exploring Hybrid CNN-transformers with Block-wisely Self-supervised Neural Architecture Search
Stars: ✭ 125 (+443.48%)
Mutual labels:  transformer
json-to-html-converter
Converts JSON data to HTML table with collapsible details view for nested objects.
Stars: ✭ 13 (-43.48%)
Mutual labels:  transform
NiuTrans.NMT
A Fast Neural Machine Translation System. It is developed in C++ and resorts to NiuTensor for fast tensor APIs.
Stars: ✭ 112 (+386.96%)
Mutual labels:  transformer
GTSRB Keras STN
German Traffic Sign Recognition Benchmark, Keras implementation with Spatial Transformer Networks
Stars: ✭ 48 (+108.7%)
Mutual labels:  transformer

Transform GraphQL

npm npm downloads npm downloads

We use GraphQL transformers. Examples are Graphback, Dgraph, AWS Amplify. This library provides function that given any GraphQL schema creates new GraphQL schemas basing on transformer functions.

Installation

npm i transform-graphql

How it works

Provide original schema with your transformer directives and an array of transformer functions defined by TransformerDef type

import { TransformGraphQLSchema } from 'transform-graphql';

const transformedSchema = TransformGraphQLSchema({ 
    schema: inputSchema, 
    transformers: [transformerCRUD] 
});

This short example simply shows what transform GraphQL is about:

Given the schema:

type Post @model{
    name: String!
    content: String!
    createdAt: String!
}

type Query{
    version:String
}
type Mutation{
    version:String
}

directive @model on OBJECT

where model is our actual transformer

We expect schema to be transformed into

directive @model on OBJECT

input CreatePost{
    name: String!
    content: String!
    createdAt: String!
}

input DetailsPost{
    id: String!
}

type Mutation{
    version: String
    post: PostMutation
}

type Post @model{
    name: String!
    content: String!
    createdAt: String!
}

type PostMutation{
    create(
            post: CreatePost
    ): String!
    update(
            post: UpdatePost
            details: DetailsPost
    ): String!
    remove(
            details: DetailsPost
    ): String!
}

type PostQuery{
    list: [Post!]!
    getByDetails(
            details: DetailsPost
    ): Post
}

type Query{
    version: String
    post: PostQuery
}
input UpdatePost{
    name: String!
    content: String!
    createdAt: String!
}
schema{
    query: Query,
    mutation: Mutation
}

And the transformer code should look like this

const inputSchema = `
type Post @model{
    name: String!
    content: String!
    createdAt: String!
}

type Query{
    version:String
}
type Mutation{
    version:String
}`
const transformerCRUD: TransformerDef = {
  transformer: ({ field, operations }) => {
    if (!field.args) {
      throw new Error('Model can be used only for types');
    }
    if (!operations.query) {
      throw new Error('Query type required');
    }
    if (!operations.mutation) {
      throw new Error('Query type required');
    }
    return `
      input Create${field.name}{
          ${TreeToGraphQL.parse({ nodes: field.args })}
      }
      input Update${field.name}{
          ${TreeToGraphQL.parse({ nodes: field.args })}
      }
      input Details${field.name}{
          id: String!
      }
      type ${field.name}Query{
          list: [${field.name}!]!
          getByDetails(details: Details${field.name}): ${field.name}
      }
      type ${field.name}Mutation{
          create( ${field.name[0].toLowerCase() + field.name.slice(1)}: Create${field.name} ): String!
          update( ${field.name[0].toLowerCase() + field.name.slice(1)}: Update${field.name}, details: Details${
      field.name
    } ): String!
          remove( details: Details${field.name} ): String!
      }
      extend type ${operations.query.name}{
          ${field.name[0].toLowerCase() + field.name.slice(1)}: ${field.name}Query
      }
      extend type ${operations.mutation.name}{
          ${field.name[0].toLowerCase() + field.name.slice(1)}: ${field.name}Mutation
      }
      `;
  },
  directiveName: 'model',
};
const transformedSchema = TransformGraphQLSchema({ schema: GraphQLTransform, transformers: [transformerCRUD] });
//transfomed schema should look like in the example

Roadmap

  • provide CLI
  • provide examples
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].