0.0.1-alpha16 • Published 5 months ago

@sf-explorer/soql-to-graphql v0.0.1-alpha16

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

SOQL to GraphQL

Transform your SOQL into GraphQL with ease

logo

Having challenges with GraphQL syntax? Already an SOQL ninja 🥷🏿? soql-to-graphql is for you.

Check out the Playground

Installation

npm i @sf-explorer/soql-to-graphql

Usage

Query and sub query

var converter = require('@sf-explorer/soql-to-graphql').default

console.log(converter('Select Id, Name, (select Id from Opportunities) from Account limit 3'))
{
  uiapi {
    query {
      Account(first: 3) {
        edges {
          node {
            Id
            Name {
              value
            }
            Opportunities {
              edges {
                node {
                  Id
                }
              }
            }
          }
        }
      }
    }
  }
}

Query with Apex Binding

var converter = require('@sf-explorer/soql-to-graphql').default

const input = {
  criteria: 'String="%"'
}

const res = converter(`select Id, Name, (select Name from Opportunities) 
    from Account 
        where Name like :criteria
        order by CreationDate
        limit 3`), input)

console.log(res)
query ($criteria: String = "%") {
  uiapi {
    query {
      Account(
        first: 3
        where: {Name: {like: $criteria}}
        orderBy: {CreationDate: {order: ASC}}
      ) {
        edges {
          node {
            Id
            Name {
              value
            }
            Opportunities {
              edges {
                node {
                  Name {
                    value
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Credits

This utility would be nothing without these 2 powerful libraries:

0.0.1-alpha16

5 months ago

0.0.1-alpha15

5 months ago

0.0.1-alpha14

5 months ago

0.0.1-alpha13

6 months ago

0.0.1-alpha12

6 months ago

0.0.1-alpha11

6 months ago

0.0.1-alpha10

6 months ago

0.0.1-alpha9

6 months ago

0.0.1-alpha8

6 months ago

0.0.1-alpha7

6 months ago

0.0.1-alpha6

6 months ago

0.0.1-alpha5

6 months ago

0.0.1-alpha4

6 months ago

0.0.1-alpha3

6 months ago

0.0.1-alpha2

6 months ago

0.0.1-alpha1

6 months ago