UNPKG

@wundergraph/orm

Version:
88 lines (86 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const graphql_1 = require("graphql"); const src_1 = require("../src"); describe('e2e', () => { // // all of this would be code-generated // // @note ideally this is code-generated as type system definition AST objects const schema = (0, graphql_1.buildSchema)(` type Query { simple: Boolean getCityByName( name: String! country: String ): City } type City { id: String name: String country: String coord( required: String! ): Coordinates } type Coordinates { x: Int! y: Int! zs( foo: String ): [String!]! } `); it('supports scalar queries', async () => { const executor = { execute(_document, _variables) { return Promise.resolve({ simple: true, }); }, }; const { query } = new src_1.OperationCreator({ schema, executor, namespace: 'foo', }); const result = await query('simple').exec(); expect(result).toBe(true); }); it('supports object type queries', async () => { const executor = { execute(_document, _variables) { return Promise.resolve({ getCityByName: { id: '001', name: 'Los Angeles', coord: { x: 0, y: 1, zs: ['a'], }, }, }); }, }; const { query } = new src_1.OperationCreator({ schema, executor, namespace: 'foo', }); const result = await query('getCityByName') .select('id', 'name', 'coord.x', 'coord.y', 'coord.zs') .where({ name: 'abc', coord: { required: '', zs: { foo: 'bar' } } }) .exec(); expect(result).toEqual({ id: '001', name: 'Los Angeles', coord: { x: 0, y: 1, zs: ['a'], }, }); }); }); //# sourceMappingURL=e2e.test.js.map