-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: no schema required for document object mapping (#1160)
- Loading branch information
1 parent
3c0a60c
commit fc13916
Showing
90 changed files
with
1,239 additions
and
532 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import type { Schema } from '../1_Schema/__.js' | ||
import type { Select } from '../2_Select/__.js' | ||
import type { CustomScalarsIndex, SchemaIndex } from '../4_generator/generators/SchemaIndex.js' | ||
import { toGraphQLDocument } from './nodes/Document.js' | ||
|
||
export const toGraphQL = (input: { | ||
schema: Schema.Index | ||
schema: SchemaIndex | ||
document: Select.Document.DocumentNormalized | ||
customScalarsIndex?: CustomScalarsIndex | ||
// we can probably remove this. was an idea that was aborted. Do we need scalar hook? | ||
// hooks?: Context['hooks'] | ||
}) => { | ||
return toGraphQLDocument( | ||
{ | ||
schema: input.schema, | ||
captures: { | ||
customScalarOutputs: [], | ||
variables: [], | ||
}, | ||
const context = { | ||
schema: input.schema, | ||
captures: { | ||
customScalarOutputs: [], | ||
variables: [], | ||
}, | ||
[], | ||
input.document, | ||
) | ||
// hooks: input.hooks, | ||
} | ||
|
||
// const location: Location = [] | ||
const customScalarsIndex: CustomScalarsIndex = input.customScalarsIndex ?? {} | ||
|
||
return toGraphQLDocument(context, customScalarsIndex, input.document) | ||
} |
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,23 +1,28 @@ | ||
import { Nodes } from '../../../lib/graphql-plus/_Nodes.js' | ||
import type { Schema } from '../../1_Schema/__.js' | ||
import type { Select } from '../../2_Select/__.js' | ||
import type { GraphQLNodeMapper } from '../types.js' | ||
import { Select } from '../../2_Select/__.js' | ||
import { advanceIndex, type GraphQLNodeMapper } from '../types.js' | ||
import { toGraphQLValue } from './Value.js' | ||
|
||
export interface Argument { | ||
name: string | ||
value: Select.Arguments.ArgValue | ||
} | ||
|
||
export const toGraphQLArgument: GraphQLNodeMapper< | ||
Nodes.ArgumentNode, | ||
[arg: { | ||
name: string | ||
type: Schema.Input.Any | ||
value: Select.Arguments.ArgValue | ||
}] | ||
[arg: Argument] | ||
> = ( | ||
context, | ||
location, | ||
index, | ||
arg, | ||
) => { | ||
return Nodes.Argument({ | ||
name: Nodes.Name({ value: arg.name }), | ||
value: toGraphQLValue(context, location, arg.type, arg.value), | ||
}) | ||
const value = toGraphQLValue( | ||
{ ...context, value: { isEnum: Select.Arguments.isEnumKey(arg.name) } }, | ||
advanceIndex(index, arg.name), | ||
arg.value, | ||
) | ||
|
||
const name = Nodes.Name({ value: arg.name.replace(Select.Arguments.enumKeyPrefixPattern, ``) }) | ||
|
||
return Nodes.Argument({ name, value }) | ||
} |
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.