luizfonseca / graphql-v

GraphQL for V

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphQL for the V language

Current state

Work in progress.

  • Language Parser (lexer, parser implementation)
  • Fixtures are covered 100% (GH, Simple)
  • Integration tests
  • Schema execute
  • Publish to VPM
  • Documentation

Usage

Parsing a .graphql definition file

You can parse any string/file using the .parse function. It returns a DocumentNode with al the definitions that were parsed, in a tree structure.

import graphql
import os

fn main() {
    // For files
    file := os.read_file('path-to-file.graphql')

    // For string inputs
    // input := 'query {
    // myQuery(id: 1) {
    //  name
    //  age
    // }
    //}'

    // max_tokens: number of tokens to parse.
    // Increasing this means supporting longer queries/schema definitions
    doc := graphql.parse(file, graphql.ParserOptions{ max_tokens: 25_000 })

    dump(doc.token_count)
    dump(doc.definitions)
}

Links

Notes

  • This package is inspired by the work of the GraphQL.js package and as such is not yet perfected for the V lang.

Contributing

  • Feedbacks/PRs are welcome, but keep in mind this is still a work in progress.

Credits

About

GraphQL for V

License:MIT License


Languages

Language:V 100.0%