FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
flesch
fleschaltairClient
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 miliseconds.
Sign up now
Code
/
Code
/
Search
main.tsx
https://flesch--fdc177ce279a11f09d52569c3dd06744.web.val.run
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

HTTP
  • main.tsx
    flesch--fd…44.web.val.run
Code
README.md
H
main.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.