FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
flesch

flesch

altairClient

Public
Like
1
altairClient
Home
Code
2
README.md
H
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
11/4/2024
README.md

Altair GraphQL Client

Create val
import { altairClient } from "https://esm.town/v/flesch/altairClient"; import { graphql, GraphQLObjectType, GraphQLSchema, GraphQLString } from "https://esm.sh/graphql"; // Define the GraphQL schema const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: "Query", fields: { hello: { type: GraphQLString, resolve: () => "Hello from Val Town GraphQL API!", }, }, }), }); // Function to handle GraphQL requests async function handleGraphQLRequest(request: Request): Promise<Response> { const { query, variables } = await request.json(); const result = await graphql({ schema, source: query, variableValues: variables, }); return new Response(JSON.stringify(result), { headers: { "Content-Type": "application/json" }, }); } // HTTP handler function export default altairClient(async function(req: Request): Promise<Response> { if (req.method === "POST") { return handleGraphQLRequest(req); } else { return new Response("This endpoint only accepts POST requests for GraphQL queries.", { status: 405 }); } });

↑ https://www.val.town/v/flesch/graphqlAPIEndpoint

Migrated from folder: GraphQL/altairClient

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
Ā© 2025 Val Town, Inc.