https://github.com/thetarnav/odin-graphql-parser
GraphQL schema parser written in Odin
https://github.com/thetarnav/odin-graphql-parser
graphql odin odinlang parser
Last synced: 3 months ago
JSON representation
GraphQL schema parser written in Odin
- Host: GitHub
- URL: https://github.com/thetarnav/odin-graphql-parser
- Owner: thetarnav
- License: mit
- Created: 2024-03-15T21:21:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-30T22:03:51.000Z (12 months ago)
- Last Synced: 2025-02-04T07:15:03.684Z (3 months ago)
- Topics: graphql, odin, odinlang, parser
- Language: Odin
- Homepage:
- Size: 102 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
- awesome-odin - GraphQL Parser - graphql-parser/blob/main/license) | Webdev (Libraries / Webdev)
- awesome-odin - GraphQL Parser - graphql-parser/blob/main/license) | Webdev (Libraries / Webdev)
README
# Odin GraphQL Parser
This is a GraphQL language parser based on the [GraphQL spec](https://spec.graphql.org/October2021) written in [Odin](https://odin-lang.org/).
Currently only parsing the schema is supported.
## Usage
```odin
package exampleimport "core:fmt"
import gql "odin-graphql-parser"schema_src := #load("schema.gql", string)
main :: proc() {
schema := gql.schema_make()
err := gql.schema_parse(&schema, schema_src)
defer gql.schema_delete(schema) // Or free the used allocatorif err != nil {
fmt.printfln("Error parsing schema: %v", err)
return
}for type in schema.types {
fmt.printfln("Type: %s", type.name)
}
}
``````gql
# schema.gql
schema {
query: Root
}
type Root {
test: Test
}
type Test implements Node {
name: String!
items: [Item]!
}
type Item implements Node {
name: String
color: Color
}
interface Node {
id: ID!
}
enum Color {
RED
GREEN
BLUE
}
```