0.1.4 • Published 10 months ago

@sf-explorer/soql-to-graphql v0.1.4

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

SOQL to GraphQL

npm version

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.1.4

10 months ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.2

1 year ago

0.1.3

12 months ago

0.0.1-alpha16

2 years ago

0.0.1-alpha15

2 years ago

0.0.1-alpha14

2 years ago

0.0.1-alpha13

2 years ago

0.0.1-alpha12

2 years ago

0.0.1-alpha11

2 years ago

0.0.1-alpha10

2 years ago

0.0.1-alpha9

2 years ago

0.0.1-alpha8

2 years ago

0.0.1-alpha7

2 years ago

0.0.1-alpha6

2 years ago

0.0.1-alpha5

2 years ago

0.0.1-alpha4

2 years ago

0.0.1-alpha3

2 years ago

0.0.1-alpha2

2 years ago

0.0.1-alpha1

2 years ago