Skip to content

Commit

Permalink
chore: update dev deps (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Jan 26, 2023
1 parent 7a644e7 commit 99f6763
Show file tree
Hide file tree
Showing 26 changed files with 1,570 additions and 3,299 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
environment: [dom, node]
graphql-version: [14, 15, 16]
name: Node ${{ matrix.node }} @env ${{matrix.environment}} with grahpql@${{ matrix.graphql-version }}
node: [16, 18]
environment: [happy-dom, node]
name: Node ${{ matrix.node }} @env ${{matrix.environment}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
- uses: prisma/action-node-cache-dependencies@main
- run: yarn add graphql@${{ matrix.graphql-version }}
- run: yarn build
- run: yarn test:${{ matrix.environment }}
env:
GRAPHQL_VERSION: ${{ matrix.graphql-version }}
- run: yarn test --environment ${{ matrix.environment }}
24 changes: 1 addition & 23 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
name: trunk
on:
push:
branches: [master]
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
environment: [dom, node]
graphql-version: [14, 15, 16]
name: Node ${{ matrix.node }} @env ${{matrix.environment}} with grahpql@${{ matrix.graphql-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
- run: yarn install
- run: yarn add graphql@${{ matrix.graphql-version }}
- run: yarn build
- run: yarn test:${{ matrix.environment }}
env:
GRAPHQL_VERSION: ${{ matrix.graphql-version }}

release-canary:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: prisma-labs/dripip@master
with:
Expand Down
59 changes: 24 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"apollo"
],
"author": {
"name" : "Jason Kuhrt",
"email" : "jasonkuhrt@me.com",
"url" : "https://kuhrt.me"
"name": "Jason Kuhrt",
"email": "jasonkuhrt@me.com",
"url": "https://kuhrt.me"
},
"license": "MIT",
"bugs": {
Expand All @@ -36,13 +36,10 @@
"scripts": {
"build:docs": "doctoc README.md --notitle",
"dev": "rm -rf dist && tsc --watch",
"dev:test": "jest --watch",
"format": "prettier --write .",
"prepublishOnly": "yarn build",
"build": "rm -rf dist && tsc -d",
"test:node": "jest --testEnvironment node",
"test:dom": "jest --testEnvironment jsdom",
"test": "yarn test:node && yarn test:dom",
"build": "rm -rf dist && tsc --project tsconfig.build.json",
"test": "vitest",
"test:coverage": "yarn test --coverage",
"release:stable": "dripip stable",
"release:preview": "dripip preview",
Expand All @@ -59,35 +56,27 @@
},
"devDependencies": {
"@prisma-labs/prettier-config": "^0.1.0",
"@types/body-parser": "^1.19.1",
"@types/express": "^4.17.13",
"@types/body-parser": "^1.19.2",
"@types/express": "^4.17.16",
"@types/extract-files": "^8.1.1",
"@types/graphql-upload": "^8.0.6",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.3",
"@types/ws": "^8.2.3",
"abort-controller": "^3.0.0",
"apollo-server-express": "^3.5.0",
"body-parser": "^1.19.0",
"doctoc": "^2.0.1",
"@types/node": "^18.11.18",
"@types/ws": "^8.5.4",
"apollo-server-express": "^3.11.1",
"body-parser": "^1.20.1",
"doctoc": "^2.2.1",
"dripip": "^0.10.0",
"express": "^4.17.3",
"fetch-cookie": "^1.0.0",
"get-port": "^5.1.1",
"graphql": "16",
"express": "^4.18.2",
"fetch-cookie": "^2.1.0",
"get-port": "^6.1.2",
"graphql": "^16.6.0",
"graphql-tag": "^2.12.5",
"graphql-upload": "^12.0.0",
"graphql-ws": "^5.6.0",
"jest": "^27.0.6",
"prettier": "^2.3.2",
"ts-jest": "^27.0.4",
"type-fest": "^1.2.2",
"typescript": "^4.8.4",
"ws": "^8.2.3"
"graphql-ws": "^5.11.2",
"happy-dom": "^8.1.5",
"prettier": "^2.8.3",
"type-fest": "^3.5.3",
"typescript": "^4.9.4",
"vitest": "^0.28.2",
"ws": "^8.12.0"
},
"prettier": "@prisma-labs/prettier-config",
"jest": {
"preset": "ts-jest",
"snapshotResolver": "<rootDir>/snapshot-resolver.js"
}
"prettier": "@prisma-labs/prettier-config"
}
26 changes: 0 additions & 26 deletions snapshot-resolver.js

This file was deleted.

7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export class GraphQLClient {
: [variables: V, requestHeaders?: Dom.RequestInit['headers']]
): Promise<T> {
const [variables, requestHeaders] = variablesAndRequestHeaders
// @ts-ignore
const requestOptions = parseRequestArgs(documentOrOptions, variables, requestHeaders)

let {
Expand All @@ -319,6 +320,7 @@ export class GraphQLClient {
fetchOptions.signal = requestOptions.signal
}

// @ts-ignore
const { query, operationName } = resolveRequestDocument(requestOptions.document)

return makeRequest({
Expand Down Expand Up @@ -561,6 +563,7 @@ export async function rawRequest<T = any, V extends Variables = Variables>(
*/
export async function request<T = any, V extends Variables = Variables>(
url: string,
// @ts-ignore
document: RequestDocument | TypedDocumentNode<T, V>,
...variablesAndRequestHeaders: VariablesAndRequestHeaders<V>
): Promise<T>
Expand All @@ -569,9 +572,11 @@ export async function request<T = any, V extends Variables = Variables>(
): Promise<T>
export async function request<T = any, V extends Variables = Variables>(
urlOrOptions: string | RequestExtendedOptions<V, T>,
// @ts-ignore
document?: RequestDocument | TypedDocumentNode<T, V>,
...variablesAndRequestHeaders: VariablesAndRequestHeaders<V>
): Promise<T> {
// @ts-ignore
const requestOptions = parseRequestExtendedArgs<V>(urlOrOptions, document, ...variablesAndRequestHeaders)
const client = new GraphQLClient(requestOptions.url)
return client.request<T, V>({
Expand All @@ -580,7 +585,7 @@ export async function request<T = any, V extends Variables = Variables>(
}

/**
* Send a batch of GraphQL Document to the GraphQL server for exectuion.
* Send a batch of GraphQL Document to the GraphQL server for execution.
*
* @example
*
Expand Down
15 changes: 9 additions & 6 deletions tests/__helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { ApolloServer } from 'apollo-server-express'
import body from 'body-parser'
import express, { Application, Request } from 'express'
import getPort from 'get-port'
import { graphqlUploadExpress } from 'graphql-upload'
import { createServer, Server } from 'http'
import { JsonObject } from 'type-fest'
import { beforeAll, afterEach, afterAll, beforeEach } from 'vitest'

type CapturedRequest = Pick<Request, 'headers' | 'method' | 'body'>

Expand Down Expand Up @@ -88,8 +88,12 @@ export function setupTestServer<T extends MockSpec | MockSpecBatch = MockSpec>(d
})
})

afterAll((done) => {
ctx.nodeServer.close(done)
afterAll(async () => {
await new Promise((resolve) => {
ctx.nodeServer?.close(() => {
resolve(undefined)
})
})
})

return ctx
Expand All @@ -102,7 +106,6 @@ export async function startApolloServer({ typeDefs, resolvers }: ApolloServerCon

const apolloServer = new ApolloServer({ typeDefs, resolvers })

app.use(graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }))
await apolloServer.start()
apolloServer.applyMiddleware({ app: app as any })

Expand All @@ -127,8 +130,8 @@ export function createApolloServerContext({ typeDefs, resolvers }: ApolloServerC
})

afterEach(async () => {
await new Promise<void>((res, rej) => {
ctx.server.close((e) => (e ? rej(e) : res()))
await new Promise((res) => {
ctx.server?.close(() => res(undefined)) ?? res(undefined)
})
})

Expand Down
34 changes: 34 additions & 0 deletions tests/__snapshots__/document-node.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Vitest Snapshot v1

exports[`accepts graphql DocumentNode as alternative to raw string 1`] = `
{
"requests": [
{
"body": {
"query": "{
query {
users
}
}",
},
"headers": {
"accept": "*/*",
"accept-encoding": "gzip,deflate",
"connection": "close",
"content-length": "43",
"content-type": "application/json",
"host": "DYNAMIC",
"user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
},
"method": "POST",
},
],
"spec": {
"body": {
"data": {
"foo": 1,
},
},
},
}
`;
33 changes: 33 additions & 0 deletions tests/__snapshots__/gql.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Vitest Snapshot v1

exports[`gql > passthrough allowing benefits of tooling for gql template tag 1`] = `
{
"requests": [
{
"body": {
"operationName": "allUsers",
"query": "query allUsers {
users
}",
},
"headers": {
"accept": "*/*",
"accept-encoding": "gzip,deflate",
"connection": "close",
"content-length": "67",
"content-type": "application/json",
"host": "DYNAMIC",
"user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
},
"method": "POST",
},
],
"spec": {
"body": {
"data": {
"foo": 1,
},
},
},
}
`;
1 change: 1 addition & 0 deletions tests/batching.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest'
import { batchRequests } from '../src'
import { setupTestServer, MockSpecBatch } from './__helpers'

Expand Down
1 change: 1 addition & 0 deletions tests/custom-fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GraphQLClient } from '../src'
import { setupTestServer } from './__helpers'
import fetch from 'cross-fetch'
import { expect, test } from 'vitest'

const ctx = setupTestServer()

Expand Down
1 change: 1 addition & 0 deletions tests/document-node.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import graphqlTag from 'graphql-tag'
import { expect, it } from 'vitest'
import { request } from '../src'
import { setupTestServer } from './__helpers'

Expand Down
1 change: 1 addition & 0 deletions tests/endpoint.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, test } from 'vitest'
import { GraphQLClient } from '../src'
import { setupTestServer } from './__helpers'

Expand Down
1 change: 1 addition & 0 deletions tests/errorPolicy.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest'
import { GraphQLClient } from '../src'
import { setupTestServer } from './__helpers'

Expand Down
Loading

0 comments on commit 99f6763

Please sign in to comment.