-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7c4a60
commit 4cdb0bd
Showing
22 changed files
with
245 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'nx-plugin-graphql-mesh': major | ||
--- | ||
|
||
Add mesh `validate` executor |
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
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
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 was deleted.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
libs/nx-plugin-graphql-mesh/src/executors/validate/hasher.spec.ts
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,27 @@ | ||
import { Hasher, HasherContext } from '@nrwl/devkit'; | ||
|
||
import { validateHasher } from './hasher'; | ||
|
||
describe('validateHasher', () => { | ||
it('should generate hash', async () => { | ||
const mockHasher: Hasher = { | ||
hashTaskWithDepsAndContext: jest | ||
.fn() | ||
.mockReturnValue({ value: 'hashed-task' }), | ||
} as unknown as Hasher; | ||
const hash = await validateHasher( | ||
{ | ||
id: 'my-task-id', | ||
target: { | ||
project: 'proj', | ||
target: 'target', | ||
}, | ||
overrides: {}, | ||
}, | ||
{ | ||
hasher: mockHasher, | ||
} as unknown as HasherContext | ||
); | ||
expect(hash).toEqual({ value: 'hashed-task' }); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
libs/nx-plugin-graphql-mesh/src/executors/validate/hasher.ts
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,12 @@ | ||
import { CustomHasher } from '@nrwl/devkit'; | ||
|
||
/** | ||
* This is a boilerplate custom hasher that matches | ||
* the default Nx hasher. If you need to extend the behavior, | ||
* you can consume workspace details from the context. | ||
*/ | ||
export const validateHasher: CustomHasher = async (task, context) => { | ||
return context.hasher.hashTaskWithDepsAndContext(task); | ||
}; | ||
|
||
export default validateHasher; |
27 changes: 27 additions & 0 deletions
27
libs/nx-plugin-graphql-mesh/src/executors/validate/schema.json
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,27 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"title": "Start executor", | ||
"description": "Validates artifacts", | ||
"type": "object", | ||
"properties": { | ||
"debug": { | ||
"type": "boolean", | ||
"description": "Display debugging info.", | ||
"default": false | ||
}, | ||
"dir": { | ||
"description": "The directory containing built GraphQL Mesh assets (.mesh).", | ||
"type": "string" | ||
}, | ||
"require": { | ||
"type": "array", | ||
"description": "Loads specific require.extensions before running the codegen and reading the configuration.", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"default": [] | ||
} | ||
}, | ||
"required": ["dir"] | ||
} |
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,6 @@ | ||
import type { Options } from '../../utils'; | ||
|
||
type MeshValidateSchema = Options<'validate'>; | ||
|
||
export type ValidateExecutorSchema = MeshValidateSchema['args'] & | ||
MeshValidateSchema['env']; |
37 changes: 37 additions & 0 deletions
37
libs/nx-plugin-graphql-mesh/src/executors/validate/validate.impl.ts
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 type { ExecutorContext } from '@nrwl/devkit'; | ||
|
||
import { logger } from '@nrwl/devkit'; | ||
import { resolve } from 'path'; | ||
|
||
import { runMeshCli } from '../../utils/mesh-cli'; | ||
|
||
import { ValidateExecutorSchema } from './schema'; | ||
|
||
export default async function* startExecutor( | ||
options: ValidateExecutorSchema, | ||
context: ExecutorContext | ||
) { | ||
if (options.dir === undefined) { | ||
throw new Error("Please define the 'dir' value"); | ||
} | ||
|
||
logger.info('Validating GraphQL Mesh artifacts...'); | ||
|
||
await runMeshCli( | ||
'validate', | ||
{ | ||
args: { | ||
dir: resolve(context.root, options.dir), | ||
require: options.require, | ||
}, | ||
env: { | ||
debug: options.debug, | ||
}, | ||
}, | ||
context | ||
); | ||
|
||
yield { | ||
success: true, | ||
}; | ||
} |
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.