Skip to content

Commit

Permalink
move to JSR, use superfetch in tests, update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Jul 17, 2024
1 parent a50e8c0 commit 03e3b50
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 261 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ for Deno. Based on [graphql-http](https://github.com/graphql/graphql-http).
The simplest setup with `Deno.serve`:

```ts
import { GraphQLHTTP } from 'https://deno.land/x/gql@1.2.4/mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected].0'
import { GraphQLHTTP } from 'jsr:@deno-libs/gql@3.0.1/mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected].3'
import { gql } from 'https://deno.land/x/[email protected]/mod.ts'

const typeDefs = gql`
Expand Down
7 changes: 7 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
},
"test": {
"exclude": ["audit_test.ts"]
},
"name": "@deno-libs/gql",
"version": "3.0.1",
"exports": {
"./": "./mod.ts",
"./types": "./types.ts",
"./graphiql/render": "./graphiql/render.ts"
}
}
348 changes: 250 additions & 98 deletions deno.lock

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ export {
type Request as RawRequest,
type RequestParams,
} from 'npm:[email protected]'
export {
STATUS_TEXT,
type StatusCode,
} from 'https://deno.land/[email protected]/http/status.ts'
export { STATUS_TEXT, type StatusCode } from 'jsr:@std/[email protected]/status'
export { accepts } from 'jsr:@std/[email protected]/negotiation'
8 changes: 4 additions & 4 deletions examples/oak.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
Application,
Middleware,
Request as OakRequest,
type Middleware,
type Request as OakRequest,
Router,
} from 'https://deno.land/x/oak@14.2.0/mod.ts'
} from 'https://deno.land/x/oak@v16.1.0/mod.ts'
import { GraphQLHTTP } from '../mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected]'
import { gql } from 'https://deno.land/x/[email protected]/mod.ts'
Expand All @@ -27,7 +27,7 @@ const schema = makeExecutableSchema({ typeDefs, resolvers })
const handleGraphQL: Middleware = async (ctx) => {
// cast Oak request into a normal Request
const req = new Request(ctx.request.url.toString(), {
body: ctx.request.originalRequest.getBody().body,
body: await ctx.request.body.blob(),
headers: ctx.request.headers,
method: ctx.request.method,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/req-ctx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GraphQLHTTP } from '../mod.ts'
import { makeExecutableSchema } from 'npm:@graphql-tools/[email protected]'
import { gql } from 'https://deno.land/x/[email protected]/mod.ts'
import type { Request as GQLRequest } from 'npm:[email protected].0'
import type { Request as GQLRequest } from 'npm:[email protected].1'

const typeDefs = gql`
type Query {
Expand Down
5 changes: 3 additions & 2 deletions graphiql/render.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { filterXSS } from 'https://esm.sh/[email protected]/'
import { filterXSS } from 'https://esm.sh/[email protected]'
import { getLoadingMarkup } from './markup.ts'

export interface MiddlewareOptions {
Expand Down Expand Up @@ -56,6 +56,7 @@ export interface EditorColours {
}

export interface IntrospectionResult {
// deno-lint-ignore no-explicit-any
__schema: any
}

Expand Down Expand Up @@ -148,7 +149,7 @@ export function renderPlaygroundPage(options: RenderPageOptions) {
}
if (!extendedOptions.endpoint && !extendedOptions.configString) {
console.warn(
`WARNING: You didn't provide an endpoint and don't have a .graphqlconfig. Make sure you have at least one of them.`,
`WARNING: You didn't provide an endpoint and don't have a config. Make sure you have at least one of them.`,
)
} else if (extendedOptions.endpoint) {
extendedOptions.endpoint = filter(extendedOptions.endpoint || '')
Expand Down
8 changes: 4 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
accepts,
createHandler,
OperationContext,
RawRequest,
type OperationContext,
type RawRequest,
STATUS_TEXT,
type StatusCode,
} from './deps.ts'
import { accepts } from 'https://deno.land/[email protected]/http/negotiation.ts'
import { GQLOptions } from './types.ts'
import type { GQLOptions } from './types.ts'

function toRequest<Req = Request, Ctx = unknown>(
req: Pick<Request, 'method' | 'url' | 'headers' | 'text'>,
Expand Down
Loading

0 comments on commit 03e3b50

Please sign in to comment.