-
Notifications
You must be signed in to change notification settings - Fork 54
feature(scalars): support distinction between input and output generator configs #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ardeois
merged 9 commits into
ardeois:main
from
argvniyx-enroute:argv/input-output-scalars
Apr 3, 2025
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
66683e1
add input to scalar spec schema, update snapshot
argvniyx-enroute 7b9e000
rearrange specs
argvniyx-enroute bfa5db2
Add generatorMode to Options type, pass an appropriate value per node…
argvniyx-enroute e336c6c
null-check value in getGeneratorDefinition
argvniyx-enroute 1fdde47
Add example coverage to scalars/spec.ts
argvniyx-enroute 9744479
add coverage for faker
argvniyx-enroute 9410256
update README
argvniyx-enroute 65bbcad
add a type guard for InputOutputGeneratorOptions and rewrite getGener…
argvniyx-enroute d0ac383
actions/cache@v2 -> @v4
argvniyx-enroute File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should generate custom scalars for native and custom types using casual 1`] = ` | ||
exports[`Custom scalar generation using casual should generate custom scalars for native and custom types 1`] = ` | ||
" | ||
export const anA = (overrides?: Partial<A>): A => { | ||
return { | ||
|
@@ -18,31 +18,75 @@ export const aB = (overrides?: Partial<B>): B => { | |
bool: overrides && overrides.hasOwnProperty('bool') ? overrides.bool! : false, | ||
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : '[email protected]', | ||
}; | ||
}; | ||
" | ||
`; | ||
|
||
exports[`Custom scalar generation using casual should generate dynamic custom scalars for native and custom types 1`] = ` | ||
"import casual from 'casual'; | ||
|
||
casual.seed(0); | ||
|
||
export const anA = (overrides?: Partial<A>): A => { | ||
return { | ||
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : casual['integer'](...[1,100]), | ||
str: overrides && overrides.hasOwnProperty('str') ? overrides.str! : casual['string'], | ||
obj: overrides && overrides.hasOwnProperty('obj') ? overrides.obj! : aB(), | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : casual['email'], | ||
}; | ||
}; | ||
|
||
export const aB = (overrides?: Partial<B>): B => { | ||
return { | ||
int: overrides && overrides.hasOwnProperty('int') ? overrides.int! : casual['integer'](...[-100,0]), | ||
flt: overrides && overrides.hasOwnProperty('flt') ? overrides.flt! : casual['double'](...[-100,0]), | ||
bool: overrides && overrides.hasOwnProperty('bool') ? overrides.bool! : false, | ||
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : casual['email'], | ||
}; | ||
}; | ||
|
||
export const seedMocks = (seed: number) => casual.seed(seed); | ||
" | ||
`; | ||
|
||
exports[`should generate custom scalars for native and custom types using faker 1`] = ` | ||
exports[`Custom scalar generation using casual with different input/output configurations should generate distinct custom scalars for native and custom input/output types 1`] = ` | ||
" | ||
export const anA = (overrides?: Partial<A>): A => { | ||
return { | ||
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : 83, | ||
str: overrides && overrides.hasOwnProperty('str') ? overrides.str! : 'Depereo nulla calco blanditiis cornu defetiscor.', | ||
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : 82, | ||
str: overrides && overrides.hasOwnProperty('str') ? overrides.str! : 'ea corrupti qui incidunt eius consequatur blanditiis', | ||
obj: overrides && overrides.hasOwnProperty('obj') ? overrides.obj! : aB(), | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : '[email protected]', | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : '[email protected]', | ||
}; | ||
}; | ||
|
||
export const aB = (overrides?: Partial<B>): B => { | ||
return { | ||
int: overrides && overrides.hasOwnProperty('int') ? overrides.int! : -93, | ||
flt: overrides && overrides.hasOwnProperty('flt') ? overrides.flt! : -24.51, | ||
flt: overrides && overrides.hasOwnProperty('flt') ? overrides.flt! : -24.509902694262564, | ||
bool: overrides && overrides.hasOwnProperty('bool') ? overrides.bool! : false, | ||
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : 'itaque distinctio iure molestias voluptas reprehenderit quos', | ||
}; | ||
}; | ||
" | ||
`; | ||
|
||
exports[`should generate dynamic custom scalars for native and custom types using casual 1`] = ` | ||
exports[`Custom scalar generation using casual with different input/output configurations should generate distinct dynamic custom scalars for native and custom types 1`] = ` | ||
"import casual from 'casual'; | ||
|
||
casual.seed(0); | ||
|
@@ -64,11 +108,103 @@ export const aB = (overrides?: Partial<B>): B => { | |
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : casual['string'], | ||
}; | ||
}; | ||
|
||
export const seedMocks = (seed: number) => casual.seed(seed); | ||
" | ||
`; | ||
|
||
exports[`should generate dynamic custom scalars for native and custom types using faker 1`] = ` | ||
exports[`custom scalar generation using faker should generate custom scalars for native and custom types 1`] = ` | ||
" | ||
export const anA = (overrides?: Partial<A>): A => { | ||
return { | ||
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : 83, | ||
str: overrides && overrides.hasOwnProperty('str') ? overrides.str! : 'Depereo nulla calco blanditiis cornu defetiscor.', | ||
obj: overrides && overrides.hasOwnProperty('obj') ? overrides.obj! : aB(), | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : '[email protected]', | ||
}; | ||
}; | ||
|
||
export const aB = (overrides?: Partial<B>): B => { | ||
return { | ||
int: overrides && overrides.hasOwnProperty('int') ? overrides.int! : -93, | ||
flt: overrides && overrides.hasOwnProperty('flt') ? overrides.flt! : -24.51, | ||
bool: overrides && overrides.hasOwnProperty('bool') ? overrides.bool! : false, | ||
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : '[email protected]', | ||
}; | ||
}; | ||
" | ||
`; | ||
|
||
exports[`custom scalar generation using faker should generate dynamic custom scalars for native and custom types 1`] = ` | ||
"import { fakerEN as faker } from '@faker-js/faker'; | ||
|
||
faker.seed(0); | ||
|
||
export const anA = (overrides?: Partial<A>): A => { | ||
return { | ||
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : faker['number']['int'](...[{\\"min\\":1,\\"max\\":100}]), | ||
str: overrides && overrides.hasOwnProperty('str') ? overrides.str! : faker['lorem']['sentence'](), | ||
obj: overrides && overrides.hasOwnProperty('obj') ? overrides.obj! : aB(), | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : faker['internet']['email'](), | ||
}; | ||
}; | ||
|
||
export const aB = (overrides?: Partial<B>): B => { | ||
return { | ||
int: overrides && overrides.hasOwnProperty('int') ? overrides.int! : faker['number']['int'](...[{\\"min\\":-100,\\"max\\":0}]), | ||
flt: overrides && overrides.hasOwnProperty('flt') ? overrides.flt! : faker['number']['float'](...[{\\"min\\":-100,\\"max\\":0}]), | ||
bool: overrides && overrides.hasOwnProperty('bool') ? overrides.bool! : false, | ||
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : faker['internet']['email'](), | ||
}; | ||
}; | ||
|
||
export const seedMocks = (seed: number) => faker.seed(seed); | ||
" | ||
`; | ||
|
||
exports[`custom scalar generation using faker with different input/output configurations should generate distinct custom scalars for native and custom input/output types 1`] = ` | ||
" | ||
export const anA = (overrides?: Partial<A>): A => { | ||
return { | ||
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : 83, | ||
str: overrides && overrides.hasOwnProperty('str') ? overrides.str! : 'Depereo nulla calco blanditiis cornu defetiscor.', | ||
obj: overrides && overrides.hasOwnProperty('obj') ? overrides.obj! : aB(), | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : '[email protected]', | ||
}; | ||
}; | ||
|
||
export const aB = (overrides?: Partial<B>): B => { | ||
return { | ||
int: overrides && overrides.hasOwnProperty('int') ? overrides.int! : -93, | ||
flt: overrides && overrides.hasOwnProperty('flt') ? overrides.flt! : -24.51, | ||
bool: overrides && overrides.hasOwnProperty('bool') ? overrides.bool! : false, | ||
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : 'vilicus', | ||
}; | ||
}; | ||
" | ||
`; | ||
|
||
exports[`custom scalar generation using faker with different input/output configurations should generate distinct dynamic custom scalars for native and custom types 1`] = ` | ||
"import { fakerEN as faker } from '@faker-js/faker'; | ||
|
||
faker.seed(0); | ||
|
@@ -90,6 +226,12 @@ export const aB = (overrides?: Partial<B>): B => { | |
}; | ||
}; | ||
|
||
export const aC = (overrides?: Partial<C>): C => { | ||
return { | ||
anyObject: overrides && overrides.hasOwnProperty('anyObject') ? overrides.anyObject! : faker['lorem']['word'](), | ||
}; | ||
}; | ||
|
||
export const seedMocks = (seed: number) => faker.seed(seed); | ||
" | ||
`; |
This file contains hidden or 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 |
---|---|---|
|
@@ -15,4 +15,8 @@ export default buildSchema(/* GraphQL */ ` | |
flt: Float! | ||
bool: Boolean! | ||
} | ||
|
||
input C { | ||
anyObject: AnyObject! | ||
} | ||
`); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.