solid-start-create-api-graphql-handler
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

solid-start-create-api-graphql-handler

Description

solid-start-create-api-graphql-handler is a small utility function that allows to run a GraphQL server in a solid-start API route. This aims to fill this gap from the official solid-start documentation, which at the time of writing this package, there isn't any other solution out there.

Installation

npm install solid-start-create-api-graphql-handler
# pnpm i solid-start-create-api-graphql-handler
# yarn add solid-start-create-api-graphql-handler

Usage

import {createApiGraphQLHandler} from 'solid-start-create-api-graphql-handler'
import type {Handler} from 'solid-start-create-api-graphql-handler'

// Implement GraphQL schema
const typeDefs = gql``
// Implement GraphQL resolvers
const resolvers = {}

const server = new ApolloServer({ typeDefs, resolvers })
await server.start()

type Data = Record<string, unknown>

const handler: Handler<Data> = (res) => {
    if(res.success === false){
        const {errors} = res
        // process error response from the server
    }
    const {data} = res
    // process response from the server
}

export const POST = createApiGraphQLHandler({
    server,
    handler
})

Package Sidebar

Install

npm i solid-start-create-api-graphql-handler

Weekly Downloads

2

Version

0.0.3

License

ISC

Unpacked Size

19.7 kB

Total Files

32

Last publish

Collaborators

  • mariosimou