-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lift inputs to operation variables (#1151)
- Loading branch information
1 parent
3895cd0
commit ade5a3e
Showing
170 changed files
with
4,040 additions
and
3,169 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 |
---|---|---|
@@ -1 +1 @@ | ||
export { print as document } from '../layers/4_document/print.js' | ||
export { toGraphQLDocument as document } from '../layers/3_SelectionSetGraphqlMapper/nodes/Document.js' |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from '../layers/1_Schema/__.js' | ||
export { SelectionSet } from '../layers/2_SelectionSet/__.js' | ||
export { Select } from '../layers/2_Select/__.js' | ||
export { ResultSet } from '../layers/3_ResultSet/__.js' |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Hybrid } from './Hybrid/__.js' | ||
|
||
export interface Directive { | ||
name: string | ||
arguments: Record<string, { | ||
name: string | ||
type: Hybrid.Scalar.$Any | ||
}> | ||
} | ||
|
||
export const IncludeDirective: Directive = { | ||
name: `include`, | ||
arguments: { | ||
if: { | ||
name: `if`, | ||
type: Hybrid.Scalar.Boolean, | ||
}, | ||
}, | ||
} | ||
|
||
export const SkipDirective: Directive = { | ||
name: `skip`, | ||
arguments: { | ||
if: { | ||
name: `if`, | ||
type: Hybrid.Scalar.Boolean, | ||
}, | ||
}, | ||
} | ||
|
||
export const standardDirectivesByName = { | ||
include: IncludeDirective, | ||
skip: SkipDirective, | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './typeGroups.js' | ||
export * from './types/Enum.js' | ||
export * from './types/Scalar/__.js' |
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,3 @@ | ||
import type { Enum, Scalar } from './_.js' | ||
|
||
export type $Any = Enum | Scalar.$Any |
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
2 changes: 1 addition & 1 deletion
2
src/layers/1_Schema/Args.ts → src/layers/1_Schema/Input/Args.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { Input } from './_.js' | ||
import type { Input } from './__.js' | ||
|
||
type InputFields = Record<string, any> | ||
|
||
|
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
23 changes: 13 additions & 10 deletions
23
src/layers/1_Schema/Field.ts → src/layers/1_Schema/Output/types/Field.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
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
export * from './Args.js' | ||
export { type RootTypeName } from './core/helpers.js' | ||
export { readMaybeThunk, type RootTypeName } from './core/helpers.js' | ||
export * from './core/Index.js' | ||
export * from './core/Named/__.js' | ||
export * from './Field.js' | ||
export * as Directives from './Directives.js' | ||
export * from './Hybrid/__.js' | ||
export * from './Hybrid/types/Enum.js' | ||
export * from './Hybrid/types/Scalar/__.js' | ||
export * from './Input/__.js' | ||
export * from './Input/Args.js' | ||
export * from './Input/types/InputObject.js' | ||
export * from './Output/__.js' | ||
export * from './Output/types/__typename.js' | ||
export * from './Output/types/Field.js' | ||
export * from './Output/types/Interface.js' | ||
export { Object$, type Object$2 } from './Output/types/Object.js' | ||
export * from './Output/types/Union.js' |
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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import type { SelectionSet } from './_.js' | ||
import { Arguments, Directive, Indicator, InlineFragment, SelectAlias, SelectScalarsWildcard } from './_.js' | ||
|
||
export type ParsedSelection = | ||
| { | ||
type: 'Arguments' | ||
arguments: Record<string, any> | ||
} | ||
| { | ||
/** | ||
* When undefined is passed to a directive. | ||
*/ | ||
type: 'DirectiveNoop' | ||
} | ||
| { | ||
type: 'Directive' | ||
name: string | ||
argumentsInput: unknown | ||
arguments: Record<string, any> | ||
} | ||
| { | ||
type: 'InlineFragment' | ||
typeCondition: string | null | ||
selectionSets: SelectionSet.AnySelectionSet[] | ||
} | ||
| { | ||
type: 'ScalarsWildcard' | ||
} | ||
| { | ||
type: 'SelectionSet' | ||
name: string | ||
selectionSet: SelectionSet.AnySelectionSet | ||
} | ||
| { | ||
type: 'Indicator' | ||
name: string | ||
select: boolean | ||
} | ||
| { | ||
type: 'Alias' | ||
name: string | ||
aliases: SelectAlias.SelectAliasMultiple | ||
} | ||
|
||
export const parseSelection = (key: string, value: any): ParsedSelection => { | ||
if (key === Arguments.key) { | ||
return { | ||
type: `Arguments`, | ||
arguments: value, | ||
} | ||
} | ||
|
||
const directiveName = Directive.parseKey(key) | ||
if (directiveName) { | ||
// @ts-expect-error fixme | ||
const directiveDef = Directive.definitionsByName[directiveName] | ||
if (!directiveDef) { | ||
throw new Error(`Unknown directive ${key}.`) | ||
} | ||
if (value === undefined) { | ||
return { | ||
type: `DirectiveNoop`, | ||
} | ||
} | ||
return { | ||
type: `Directive`, | ||
name: directiveName, | ||
argumentsInput: value, | ||
arguments: directiveDef.normalizeArguments(value), | ||
} | ||
} | ||
|
||
if (key === SelectScalarsWildcard.key) { | ||
return { | ||
type: `ScalarsWildcard`, | ||
} | ||
} | ||
|
||
if (Indicator.isIndicator(value)) { | ||
return { | ||
type: `Indicator`, | ||
name: key, | ||
select: Indicator.isPositiveIndicator(value), | ||
} | ||
} | ||
|
||
const inlineFragment = InlineFragment.parseKey(key) | ||
if (inlineFragment) { | ||
const selectionSets = InlineFragment.normalizeInlineFragment(value) | ||
return { | ||
type: `InlineFragment`, | ||
typeCondition: inlineFragment.typeCondition, | ||
selectionSets, | ||
} | ||
} | ||
|
||
// Parse alias after inline fragment because both can have array values but the keys are distinctive | ||
if (SelectAlias.isSelectAlias(value)) { | ||
return { | ||
type: `Alias`, | ||
name: key, | ||
aliases: SelectAlias.normalizeSelectAlias(value), | ||
} | ||
} | ||
|
||
if (typeof value === `object` && value !== null) { | ||
return { | ||
type: `SelectionSet`, | ||
name: key, | ||
selectionSet: value, | ||
} | ||
} | ||
|
||
throw new Error(`Unknown selection at key ${key}.`) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './$types.js' | ||
export * from './helpers.js' | ||
export * as Include from './include.js' | ||
export * as Skip from './skip.js' |
File renamed without changes.
Oops, something went wrong.