-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e test, install peer deps, vitest projects use devdeps
- Loading branch information
Showing
15 changed files
with
733 additions
and
41 deletions.
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
e2e/auto-type-merging/__snapshots__/auto-type-merging.e2e.ts.snap
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`should execute 'GetPet' 1`] = ` | ||
{ | ||
"data": { | ||
"getPetById": { | ||
"__typename": "Pet", | ||
"id": 1, | ||
"name": "Cat 1", | ||
"vaccinated": false, | ||
}, | ||
}, | ||
} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createTenv, type Container } from '@internal/e2e'; | ||
import { beforeAll, expect, it } from 'vitest'; | ||
|
||
const { compose, service, serve, container } = createTenv(__dirname); | ||
|
||
let petstore!: Container; | ||
beforeAll(async () => { | ||
petstore = await container({ | ||
name: 'petstore', | ||
image: 'swaggerapi/petstore3:1.0.7', | ||
containerPort: 8080, | ||
healthcheck: ['CMD-SHELL', 'wget --spider http://localhost:8080'], | ||
}); | ||
}); | ||
|
||
it.concurrent.each([ | ||
{ | ||
name: 'GetPet', | ||
query: /* GraphQL */ ` | ||
query GetPet { | ||
getPetById(petId: 1) { | ||
__typename | ||
id | ||
name | ||
vaccinated | ||
} | ||
} | ||
`, | ||
}, | ||
])('should execute $name', async ({ query }) => { | ||
const { output } = await compose({ | ||
output: 'graphql', | ||
services: [petstore, await service('vaccination')], | ||
}); | ||
const { execute } = await serve({ supergraph: output }); | ||
await expect(execute({ query })).resolves.toMatchSnapshot(); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import os from 'os'; | ||
import { | ||
createTbench, | ||
createTenv, | ||
type Container, | ||
type Tbench, | ||
type TbenchResult, | ||
} from '@internal/e2e'; | ||
import { beforeAll, expect, it } from 'vitest'; | ||
|
||
const { serve, compose, service, container } = createTenv(__dirname); | ||
|
||
let tbench: Tbench; | ||
let petstore!: Container; | ||
beforeAll(async () => { | ||
tbench = await createTbench( | ||
// to give space for jest and the serve process. | ||
os.availableParallelism() - 2, | ||
); | ||
petstore = await container({ | ||
name: 'petstore', | ||
image: 'swaggerapi/petstore3:1.0.7', | ||
containerPort: 8080, | ||
healthcheck: ['CMD-SHELL', 'wget --spider http://0.0.0.0:8080'], | ||
}); | ||
}); | ||
|
||
const threshold: TbenchResult = { | ||
maxCpu: Infinity, // we dont care | ||
maxMem: 500, // MB | ||
slowestRequest: 1, // second | ||
}; | ||
|
||
it(`should perform within threshold ${JSON.stringify(threshold)}`, async () => { | ||
const { output } = await compose({ | ||
services: [petstore, await service('vaccination')], | ||
output: 'graphql', | ||
}); | ||
const server = await serve({ supergraph: output }); | ||
const result = await tbench.sustain({ | ||
server, | ||
params: { | ||
query: /* GraphQL */ ` | ||
query GetPet { | ||
getPetById(petId: 1) { | ||
__typename | ||
id | ||
name | ||
vaccinated | ||
} | ||
} | ||
`, | ||
}, | ||
}); | ||
|
||
console.debug(result); | ||
|
||
expect(result.maxCpu).toBeLessThan(threshold.maxCpu); | ||
expect(result.maxMem).toBeLessThan(threshold.maxMem); | ||
expect(result.slowestRequest).toBeLessThan(threshold.slowestRequest); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
camelCase, | ||
createFilterTransform, | ||
createNamingConventionTransform, | ||
defineConfig, | ||
loadGraphQLHTTPSubgraph, | ||
} from '@graphql-mesh/compose-cli'; | ||
import { Opts } from '@internal/testing'; | ||
import { loadOpenAPISubgraph } from '@omnigraph/openapi'; | ||
|
||
const opts = Opts(process.argv); | ||
|
||
export const composeConfig = defineConfig({ | ||
subgraphs: [ | ||
{ | ||
sourceHandler: loadOpenAPISubgraph('petstore', { | ||
source: `http://localhost:${opts.getServicePort('petstore')}/api/v3/openapi.json`, | ||
// endpoint must be manually specified because the openapi.json spec doesn't contain one | ||
endpoint: `http://localhost:${opts.getServicePort('petstore')}/api/v3`, | ||
}), | ||
transforms: [ | ||
createFilterTransform({ | ||
rootFieldFilter: (typeName, fieldName) => | ||
typeName === 'Query' && fieldName === 'getPetById', | ||
}), | ||
], | ||
}, | ||
{ | ||
sourceHandler: loadGraphQLHTTPSubgraph('vaccination', { | ||
endpoint: `http://localhost:${opts.getServicePort('vaccination')}/graphql`, | ||
}), | ||
transforms: [ | ||
createNamingConventionTransform({ | ||
fieldNames: camelCase, | ||
}), | ||
], | ||
}, | ||
], | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "@e2e/auto-type-merging", | ||
"private": true, | ||
"devDependencies": { | ||
"@graphql-mesh/compose-cli": "^1.1.1", | ||
"@graphql-mesh/cross-helpers": "^0.4.7", | ||
"@graphql-mesh/store": "^0.102.7", | ||
"@graphql-mesh/types": "^0.102.7", | ||
"@graphql-mesh/utils": "^0.102.7", | ||
"@graphql-tools/utils": "^10.5.5", | ||
"@omnigraph/openapi": "^0.107.1", | ||
"graphql": "^16.9.0", | ||
"graphql-yoga": "^5.7.0", | ||
"tslib": "^2.8.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createServer } from 'http'; | ||
import { Opts } from '@internal/testing'; | ||
import { createSchema, createYoga } from 'graphql-yoga'; | ||
|
||
export const yoga = createYoga({ | ||
schema: createSchema({ | ||
typeDefs: /* GraphQL */ ` | ||
scalar BigInt | ||
type Query { | ||
pet_by_id(id: BigInt!): Pet | ||
} | ||
type Pet { | ||
id: BigInt! | ||
vaccinated: Boolean! | ||
} | ||
`, | ||
resolvers: { | ||
Query: { | ||
pet_by_id: async (_root, args, _context, _info) => { | ||
return { | ||
id: args.id, | ||
vaccinated: false, | ||
}; | ||
}, | ||
}, | ||
}, | ||
}), | ||
}); | ||
|
||
const port = Opts(process.argv).getServicePort('vaccination', true); | ||
|
||
createServer(yoga).listen(port, () => { | ||
console.log(`Vaccination service listening on http://localhost:${port}`); | ||
}); |
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
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
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 |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
"private": true, | ||
"workspaces": [ | ||
"packages/*", | ||
"internal/*" | ||
"internal/*", | ||
"e2e/*" | ||
], | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
|
@@ -13,7 +14,8 @@ | |
"check:lint": "eslint 'packages/**/src/**/*.ts'", | ||
"check:types": "yarn tsc", | ||
"format": "yarn check:format --write", | ||
"test": "vitest" | ||
"test": "vitest --project unit", | ||
"test:e2e": "vitest --project e2e" | ||
}, | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "^4.3.1", | ||
|
@@ -25,6 +27,7 @@ | |
"prettier": "^3.3.3", | ||
"prettier-plugin-pkg": "^0.18.1", | ||
"prettier-plugin-sh": "^0.14.0", | ||
"tsx": "^4.16.5", | ||
"typescript": "^5.6.3", | ||
"typescript-eslint": "^8.9.0", | ||
"vite": "^5.4.9", | ||
|
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
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
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.