SkillAgentSearch skills...

Modif

GraphQL API Playground with cascade-like operations

Install / Use

/learn @pedropalhari/Modif
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

modif (🍖👉🥪)

modif is a small GraphQL API with transform capabilities. It takes a string input and outputs a string. Always.

TL;DR

  • Go play with it at https://modif.palhari.dev

Examples

Some cool examples to start you by:

# Operation
query UppercaseString($value: String!) {
  modify(value: $value) {
    uppercase {
      value
    }
  }
}

# Variables
{
  "value": "i'm a lowercase string"
}
# Operation
query GetEmailAddressDomain(
  $value: String!
  $arg1: String!
  $concatArg1: String!
) {
  modify(value: $value) {
    starts(arg1: $arg1) {
      removeWhiteSpace {
        concat(arg1: $concatArg1) {
          value
        }
      }
    }
  }
}

# Variables
{
  "value": "My email address is pedro@palhari.dev",
  "arg1": "@",
  "concatArg1": " is the email address' domain"
}
# Operation
query GetStreetNameFromCEP(
  $value: String!
  $arg1: String!
  $arg2: String!
  $concatArg1: String!
) {
  modify(value: $value) {
    onlyNumbers {
      viaCEP {
        between(arg1: $arg1, arg2: $arg2) {
          concat(arg1: $concatArg1) {
            value
          }
        }
      }
    }
  }
}

# Variables
{
  "value": "My house is located at 15370-496",
  "arg1": "logradouro:",
  "arg2": "|",
  "concatArg1": " is the street I live"
}

How does it work?

Using GraphQL attribute resolving as a runtime recursive transformer of the input. The GraphQL server is made of a single Object called ModifierObject.

Inside ModifierObject all the modifiers are declared and return their own ModifierObject. The only static variable is the value, a string.

Attributes are resolved at runtime using an obscure function attribute called length. This allows me to generate the arguments for this function when the server boots up.

You can check all of that, under great detail and in a manifesto-kinda way of programming on graphql/GraphQLModifiers.ts.

Contributing

Have a great idea or want to add more modifiers to it? Check out modifiers/StringModifiers.ts and make sure you read the concept on graphql/GraphQLModifiers.ts to know what I want this to eventually end.

Running locally

  • Clone the repo
  • yarn
  • Either node pm2.js or yarn dev:g
    • The latter is prefered as it has nodemon and --enable-source-maps capabilities.
    • A server will spawn under http://localhost:6780, navigate to it to query the API

Early FAQ

  • Hey, why don't you use X instead of Apollo Studio Sandbox?

I like the Sandbox. It's visually great, let me do a lot of work visually.

  • Why can't I do Y?

Very very early stage toy. But check Contributing up above and make yourself at home.

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated4y ago
Forks0

Languages

TypeScript

Security Score

70/100

Audited on Jan 4, 2022

No findings