@xircus-web3/graph-ton
v1.0.100
Published
Xircus GraphQL SDK for TON Chain
Downloads
95
Readme
@xircus-web3/graph-ton
A GraphQL API dedicated only to interact with TON Chain and aggregate smart contracts data deployed in TON.
Documentation
Recent Changes
Installation
Install Xircus Graph SDK and its ethers peer dependency.
npm install @xircus-web3/graph-ton graphql graphql-yoga mongoose
or
yarn add @xircus-web3/graph-ton graphql graphql-yoga mongoose
Usage
- Sample setup with Mongoose, GraphQL Yoga on NextJS
- Create pages/api/graphql.js in your next app
- Make sure to have .env file DATABASE_URL=mongodburl
- to test locally .env DATABASE_URL=mongodb://localhost:27017/DATABASE_NAME
import { createYoga, createSchema } from 'graphql-yoga'
import mongoose from 'mongoose'
import { createMongo, createTonAuth, createTonQuest, createTonSchema, tonSchema } from '@xircus-web3/graph-ton'
mongoose.set('strictQuery', false)
const env = process.env.API_ENV || 'production'
const schema = createTonSchema({
// extendable graphql mutation and query
Mutation: { ... },
Query: { ... }
})
const server = createYoga({
graphqlEndpoint: '/api/graphql',
schema: createSchema(schema),
context: async({ req }) => {
// db models from any source
const models = await createMongo(mongoose, tonSchema)
// extendable services
const auth = createTonAuth(req, models)
const quest = createTonQuest(models)
// extendable params
return {
env,
models,
auth,
quest,
secret: APP_SECRET_KEY
}
}
})
export default server
Community
Check out the following places for more xircus-related content:
- Join the discussions on GitHub
- Follow @xircusweb3 on Twitter for project updates
- Share your project/organization using Xircus
- Browse the awesome-xircus list of awesome projects and resources
Support
If you find @xircus-web3/graph-ton useful, please consider supporting our development. Thank you 🙏