graphile-test 2.1.11 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -124,18 +124,20 @@ interface CreateUserResult {
124
124
  };
125
125
  }
126
126
 
127
- const res = await query<CreateUserResult>(`
128
- mutation CreateUser($input: CreateUserInput!) {
129
- createUser(input: $input) {
130
- user {
131
- id
132
- username
127
+ const res = await query<CreateUserResult, CreateUserVariables>(`
128
+ mutation CreateUser($input: CreateUserInput!) {
129
+ createUser(input: $input) {
130
+ user {
131
+ id
132
+ username
133
+ }
133
134
  }
134
135
  }
135
- }
136
- `, { input: { user: { username: 'alice' } } });
136
+ `,
137
+ { input: { user: { username: 'alice' } } }
138
+ );
137
139
 
138
- expect(res.data.createUser.user.username).toBe('alice');
140
+ expect(res.data?.createUser.user.username).toBe('alice');
139
141
  ```
140
142
 
141
143
  ## 🔧 Advanced Connection Options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-test",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "PostGraphile Testing",
6
6
  "main": "index.js",
@@ -48,5 +48,5 @@
48
48
  "launchql",
49
49
  "test"
50
50
  ],
51
- "gitHead": "dd29fa9997eb53550eaabd017e2f1664f2eb7267"
51
+ "gitHead": "d31229ead583c61febd9959e268b1de8cbf4cb72"
52
52
  }
@@ -1,16 +0,0 @@
1
- import type { GetConnectionOpts } from 'pgsql-test';
2
- import type { PgTestClient } from 'pgsql-test/test-client';
3
- import type { SeedAdapter } from 'pgsql-test/seed/types';
4
- import type { GraphQLQueryUnwrappedFn, GraphQLQueryUnwrappedFnPos } from './types';
5
- export interface GetConnectionsInput {
6
- useRoot?: boolean;
7
- schemas: string[];
8
- authRole?: string;
9
- }
10
- export declare const getConnectionsUnwrapped: (input: GetConnectionsInput & GetConnectionOpts, seedAdapters?: SeedAdapter[]) => Promise<{
11
- pg: PgTestClient;
12
- db: PgTestClient;
13
- teardown: () => Promise<void>;
14
- query: GraphQLQueryUnwrappedFn;
15
- queryPositional: GraphQLQueryUnwrappedFnPos;
16
- }>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConnectionsUnwrapped = void 0;
4
- const pgsql_test_1 = require("pgsql-test");
5
- const graphile_test_1 = require("./graphile-test");
6
- const unwrap = (res) => {
7
- if (res.errors?.length) {
8
- throw new Error(JSON.stringify(res.errors, null, 2));
9
- }
10
- if (!res.data) {
11
- throw new Error('No data returned from GraphQL query');
12
- }
13
- return res.data;
14
- };
15
- const getConnectionsUnwrapped = async (input, seedAdapters) => {
16
- const conn = await (0, pgsql_test_1.getConnections)(input, seedAdapters);
17
- const { pg, db, teardown: dbTeardown } = conn;
18
- const gqlContext = (0, graphile_test_1.GraphQLTest)(input, conn);
19
- await gqlContext.setup();
20
- const teardown = async () => {
21
- await gqlContext.teardown();
22
- await dbTeardown();
23
- };
24
- const query = async (opts) => unwrap(await gqlContext.query(opts));
25
- const queryPositional = async (query, variables, commit, reqOptions) => unwrap(await gqlContext.query({ query, variables, commit, reqOptions }));
26
- return {
27
- pg,
28
- db,
29
- teardown,
30
- query,
31
- queryPositional
32
- };
33
- };
34
- exports.getConnectionsUnwrapped = getConnectionsUnwrapped;
@@ -1,30 +0,0 @@
1
- import { getConnections as getPgConnections } from 'pgsql-test';
2
- import { GraphQLTest } from './graphile-test';
3
- const unwrap = (res) => {
4
- if (res.errors?.length) {
5
- throw new Error(JSON.stringify(res.errors, null, 2));
6
- }
7
- if (!res.data) {
8
- throw new Error('No data returned from GraphQL query');
9
- }
10
- return res.data;
11
- };
12
- export const getConnectionsUnwrapped = async (input, seedAdapters) => {
13
- const conn = await getPgConnections(input, seedAdapters);
14
- const { pg, db, teardown: dbTeardown } = conn;
15
- const gqlContext = GraphQLTest(input, conn);
16
- await gqlContext.setup();
17
- const teardown = async () => {
18
- await gqlContext.teardown();
19
- await dbTeardown();
20
- };
21
- const query = async (opts) => unwrap(await gqlContext.query(opts));
22
- const queryPositional = async (query, variables, commit, reqOptions) => unwrap(await gqlContext.query({ query, variables, commit, reqOptions }));
23
- return {
24
- pg,
25
- db,
26
- teardown,
27
- query,
28
- queryPositional
29
- };
30
- };