-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move all types to types.ts, bump deps, remove tinyhttp example
- Loading branch information
v1rtl
committed
Jul 13, 2022
1 parent
3a1ca5c
commit 65d1a2f
Showing
7 changed files
with
57 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ Universal [GraphQL](https://www.graphql.com/) HTTP middleware for Deno. | |
The simplest setup with `std/http`: | ||
|
||
```ts | ||
import { Server } from 'https://deno.land/std@0.107.0/http/server.ts' | ||
import { Server } from 'https://deno.land/std@0.148.0/http/server.ts' | ||
import { GraphQLHTTP } from '../mod.ts' | ||
import { makeExecutableSchema } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { gql } from 'https://deno.land/x/[email protected]/mod.ts' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,5 @@ | ||
import { graphql, GraphQLSchema, ExecutionResult } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import type { GraphQLArgs } from 'https://deno.land/x/[email protected]/lib/graphql.d.ts' | ||
import type { GQLRequest } from './types.ts' | ||
import type { RenderPageOptions } from './graphiql/render.ts' | ||
|
||
/** | ||
* gql options | ||
*/ | ||
export interface GQLOptions<Context = any, Req extends GQLRequest = GQLRequest> extends Omit<GraphQLArgs, 'source'> { | ||
schema: GraphQLSchema | ||
context?: (val: Req) => Context | Promise<Context> | ||
/** | ||
* GraphQL playground | ||
*/ | ||
graphiql?: boolean | ||
/** | ||
* Custom headers for responses | ||
*/ | ||
headers?: HeadersInit | ||
/** | ||
* Custom options for GraphQL Playground | ||
*/ | ||
playgroundOptions?: Omit<RenderPageOptions, 'endpoint'> | ||
} | ||
|
||
interface Params { | ||
variables?: Record<string, unknown> | ||
operationName?: string | ||
} | ||
|
||
interface QueryParams extends Params { | ||
query: string | ||
mutation?: never | ||
} | ||
|
||
interface MutationParams extends Params { | ||
mutation: string | ||
query?: never | ||
} | ||
|
||
export type GraphQLParams = QueryParams | MutationParams | ||
import { graphql, ExecutionResult } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import type { GQLOptions, GQLRequest, GraphQLParams } from './types.ts' | ||
|
||
/** | ||
* Execute a GraphQL query | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { opine, Request as OpineRequest } from 'https://deno.land/x/opine@2.1.5/mod.ts' | ||
import { opine, OpineRequest } from 'https://deno.land/x/opine@2.2.0/mod.ts' | ||
import { GraphQLHTTP } from '../mod.ts' | ||
import { makeExecutableSchema } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { gql } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { readAll } from 'https://deno.land/std@0.136.0/io/mod.ts' | ||
import { readAll } from 'https://deno.land/std@0.148.0/streams/conversion.ts' | ||
|
||
type Request = OpineRequest & { json: () => Promise<any> } | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Server } from 'https://deno.land/std@0.136.0/http/server.ts' | ||
import { Server } from 'https://deno.land/std@0.148.0/http/server.ts' | ||
import { GraphQLHTTP } from '../mod.ts' | ||
import { makeExecutableSchema } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { gql } from 'https://deno.land/x/[email protected]/mod.ts' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,47 @@ | ||
import type { GraphQLArgs } from 'https://deno.land/x/[email protected]/lib/graphql.d.ts' | ||
import type { GraphQLSchema } from 'https://deno.land/x/[email protected]/lib/type/schema.d.ts' | ||
import type { RenderPageOptions } from './graphiql/render.ts' | ||
|
||
/** | ||
* gql options | ||
*/ | ||
export interface GQLOptions<Context = any, Req extends GQLRequest = GQLRequest> extends Omit<GraphQLArgs, 'source'> { | ||
schema: GraphQLSchema | ||
context?: (val: Req) => Context | Promise<Context> | ||
/** | ||
* GraphQL playground | ||
*/ | ||
graphiql?: boolean | ||
/** | ||
* Custom headers for responses | ||
*/ | ||
headers?: HeadersInit | ||
/** | ||
* Custom options for GraphQL Playground | ||
*/ | ||
playgroundOptions?: Omit<RenderPageOptions, 'endpoint'> | ||
} | ||
|
||
interface Params { | ||
variables?: Record<string, unknown> | ||
operationName?: string | ||
} | ||
|
||
interface QueryParams extends Params { | ||
query: string | ||
mutation?: never | ||
} | ||
|
||
interface MutationParams extends Params { | ||
mutation: string | ||
query?: never | ||
} | ||
|
||
export type GraphQLParams = QueryParams | MutationParams | ||
|
||
export type GQLRequest = { | ||
url: string | ||
method: string | ||
headers: Headers | ||
json: () => Promise<any> | ||
json: () => Promise<GraphQLParams> | ||
} |