-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove request and response logic
export handler feature only
- Loading branch information
1 parent
4cde34d
commit 2ecea94
Showing
20 changed files
with
135 additions
and
3,305 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,8 +1,8 @@ | ||
{ | ||
"imports": { | ||
"https://deno.land/x/graphql_http@$VERSION/": "./", | ||
"https://deno.land/std@$VERSION/": "https://deno.land/std@0.147.0/", | ||
"https://esm.sh/graphql@$VERSION": "https://esm.sh/graphql@16.5.0", | ||
"https://deno.land/x/pure_json@$VERSION/": "https://deno.land/x/pure_json@1.0.0-beta.1/" | ||
"https://deno.land/std@$VERSION/": "https://deno.land/std@0.159.0/", | ||
"https://esm.sh/graphql@$VERSION": "https://esm.sh/v96/graphql@16.6.0", | ||
"https://deno.land/x/gql_request@$VERSION/": "https://deno.land/x/gql_request@1.0.0-beta.1/" | ||
} | ||
} |
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,95 +1,12 @@ | ||
// Copyright 2022-latest the graphqland authors. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
|
||
export { | ||
buildSchema, | ||
execute, | ||
executeSync, | ||
type ExecutionResult, | ||
getOperationAST, | ||
graphql, | ||
type GraphQLArgs, | ||
GraphQLError, | ||
type GraphQLFieldResolver, | ||
assertValidSchema, | ||
GraphQLSchema, | ||
type GraphQLTypeResolver, | ||
parse, | ||
Source, | ||
specifiedRules, | ||
validate, | ||
validateSchema, | ||
} from "https://esm.sh/v87/graphql@16.5.0"; | ||
export { | ||
contentType, | ||
parseMediaType, | ||
} from "https://deno.land/std@0.150.0/media_types/mod.ts"; | ||
export { accepts } from "https://deno.land/std@0.150.0/http/negotiation.ts"; | ||
export { | ||
isNil, | ||
isNull, | ||
isObject, | ||
isPlainObject, | ||
isString, | ||
isUndefined, | ||
} from "https://deno.land/x/isx@1.0.0-beta.19/mod.ts"; | ||
export { | ||
JSON, | ||
type json, | ||
stringify, | ||
} from "https://deno.land/x/pure_json@1.0.0-beta.1/mod.ts"; | ||
import { type json } from "https://deno.land/x/pure_json@1.0.0-beta.1/mod.ts"; | ||
} from "https://esm.sh/v96/graphql@16.6.0"; | ||
export { | ||
type RenderPageOptions, | ||
renderPlaygroundPage, | ||
} from "https://esm.sh/graphql-playground-html@1.6.30"; | ||
export { | ||
createHttpError, | ||
HttpError, | ||
Status, | ||
} from "https://deno.land/std@0.150.0/http/mod.ts"; | ||
|
||
export type PartialBy<T, K = keyof T> = | ||
Omit<T, K & keyof T> & Partial<Pick<T, K & keyof T>> extends infer U | ||
? { [K in keyof U]: U[K] } | ||
: never; | ||
|
||
export type PickBy<T, K> = { | ||
[k in keyof T as (K extends T[k] ? k : never)]: T[k]; | ||
}; | ||
|
||
export type PickRequired<T> = { | ||
[k in keyof T as Record<never, never> extends Pick<T, k> ? never : k]: T[k]; | ||
}; | ||
|
||
export type PickPartial<T> = { | ||
[k in keyof T as Record<never, never> extends Pick<T, k> ? k : never]: T[k]; | ||
}; | ||
|
||
export type jsonObject = { | ||
[k: string]: json; | ||
}; | ||
|
||
export function tryCatchSync<T>( | ||
fn: () => T, | ||
): [data: T, err: undefined] | [data: undefined, err: unknown] { | ||
try { | ||
return [fn(), undefined]; | ||
} catch (er) { | ||
return [, er]; | ||
} | ||
} | ||
|
||
export async function tryCatch<T>( | ||
fn: () => Promise<T> | T, | ||
): Promise<[data: T, err: undefined] | [data: undefined, err: unknown]> { | ||
try { | ||
return [await fn(), undefined]; | ||
} catch (er) { | ||
return [, er]; | ||
} | ||
} | ||
|
||
// deno-lint-ignore no-explicit-any | ||
export function has<T extends Record<any, any>, K extends string>( | ||
value: T, | ||
key: K, | ||
): value is T & Record<K, unknown> { | ||
return key in value; | ||
} | ||
createResponse, | ||
type ExecutionParams, | ||
} from "https://deno.land/x/graphql_response@1.0.0-beta.2/mod.ts"; | ||
export { type HttpHandler } from "https://deno.land/x/http_utils@1.0.0-beta.6/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,90 +1,5 @@ | ||
export * from "https://deno.land/std@0.150.0/testing/asserts.ts"; | ||
export * from "https://deno.land/std@0.150.0/testing/bdd.ts"; | ||
export * from "https://deno.land/std@0.150.0/media_types/mod.ts"; | ||
export * from "https://deno.land/std@0.150.0/http/mod.ts"; | ||
import { | ||
defineExpect, | ||
equal, | ||
jestMatcherMap, | ||
jestModifierMap, | ||
MatchResult, | ||
} from "https://deno.land/x/unitest@v1.0.0-beta.82/mod.ts"; | ||
import { isString } from "https://deno.land/x/isx@v1.0.0-beta.17/mod.ts"; | ||
export * from "https://esm.sh/graphql@16.5.0"; | ||
export * from "https://deno.land/std@0.159.0/testing/asserts.ts"; | ||
export * from "https://deno.land/std@0.159.0/testing/mock.ts"; | ||
export * from "https://deno.land/std@0.159.0/testing/bdd.ts"; | ||
|
||
export const expect = defineExpect({ | ||
matcherMap: { | ||
...jestMatcherMap, | ||
toError: ( | ||
actual: unknown, | ||
// deno-lint-ignore ban-types | ||
error: Function, | ||
message?: string, | ||
) => { | ||
if (!(actual instanceof Error)) { | ||
return { | ||
pass: false, | ||
expected: "Error Object", | ||
}; | ||
} | ||
|
||
if (!(actual instanceof error)) { | ||
return { | ||
pass: false, | ||
expected: `${error.name} Object`, | ||
}; | ||
} | ||
|
||
if (message) { | ||
return { | ||
pass: actual.message === message, | ||
expected: message, | ||
resultActual: actual.message, | ||
}; | ||
} | ||
|
||
return { | ||
pass: true, | ||
expected: error, | ||
}; | ||
}, | ||
toEqualIterable, | ||
}, | ||
modifierMap: jestModifierMap, | ||
}); | ||
|
||
function toEqualIterable( | ||
actual: Iterable<readonly [PropertyKey, string]>, | ||
expected: Iterable<readonly [PropertyKey, string]>, | ||
): MatchResult { | ||
const act = Object.fromEntries(actual); | ||
const exp = Object.fromEntries(expected); | ||
|
||
return { | ||
pass: equal(act, exp), | ||
expected: exp, | ||
resultActual: act, | ||
}; | ||
} | ||
|
||
export function queryString( | ||
baseURL: string | URL, | ||
urlParams: { [param: string]: string }, | ||
): string { | ||
const url = isString(baseURL) ? new URL(baseURL) : baseURL; | ||
|
||
Object.entries(urlParams).forEach(([key, value]) => { | ||
url.searchParams.set(key, value); | ||
}); | ||
|
||
return url.toString(); | ||
} | ||
|
||
export class BaseRequest extends Request { | ||
constructor(input: RequestInfo, init?: RequestInit) { | ||
const headers = new Headers(init?.headers); | ||
headers.append("accept", "application/graphql+json"); | ||
|
||
super(input, { ...init, headers }); | ||
} | ||
} | ||
export { buildSchema } from "https://esm.sh/v96/graphql@16.6.0"; |
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
Oops, something went wrong.