Skip to content

Commit

Permalink
refactor: consolidate schema type
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Oct 21, 2024
1 parent 653210d commit c29c877
Show file tree
Hide file tree
Showing 57 changed files with 1,469 additions and 1,556 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"default": "./build/entrypoints/schema.js"
}
},
"./generator-helpers/standard-scalar-types": {
"import": {
"default": "./build/entrypoints/generator-helpers/standardScalarTypes.js"
}
},
"./utilities-for-generated": {
"import": {
"default": "./build/entrypoints/utilities-for-generated.js"
Expand Down
1 change: 1 addition & 0 deletions src/entrypoints/generator-helpers/standardScalarTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../../types/Schema/types/Scalar/standardScalarTypes.js'
4 changes: 2 additions & 2 deletions src/entrypoints/utilities-for-generated.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { type Simplify } from 'type-fest'
export { type Schema as SchemaIndexBase } from '../generator/generators/Schema.js'
export * from '../layers/2_Select/__.js'
export { type ClientContext } from '../layers/6_client/fluent.js'
export type {
Expand All @@ -12,5 +11,6 @@ export type { Config } from '../layers/6_client/Settings/Config.js'
export { type Exact, type ExactNonEmpty, type UnionExpanded } from '../lib/prelude.js'
export { TypeFunction } from '../lib/type-function/__.js'
export { type GlobalRegistry } from '../types/GlobalRegistry/GlobalRegistry.js'
export { SchemaKit } from '../types/Schema/__.js'
export { Schema } from '../types/Schema/__.js'
export * from '../types/Schema/types/Scalar/standardScalarTypes.js'
export { type SchemaDrivenDataMap } from '../types/SchemaDrivenDataMap/__.js'
8 changes: 4 additions & 4 deletions src/extensions/CustomScalars/decode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Kind } from 'graphql'
import { SchemaKit } from '../../entrypoints/schema.js'
import { Schema } from '../../entrypoints/schema.js'
import type { RegisteredScalars } from '../../layers/6_client/fluent.js'
import type { Grafaid } from '../../lib/grafaid/__.js'
import { SchemaDrivenDataMap } from '../../types/SchemaDrivenDataMap/__.js'
Expand Down Expand Up @@ -59,10 +59,10 @@ const decodeResultData_ = (input: {
const sddmNode = sddmOutputField.nt

if (SchemaDrivenDataMap.isScalar(sddmNode)) {
data[k] = SchemaKit.Scalar.applyCodec(sddmNode.codec.decode, v)
data[k] = Schema.Scalar.applyCodec(sddmNode.codec.decode, v)
} else if (SchemaDrivenDataMap.isCustomScalarName(sddmNode)) {
const scalar = SchemaKit.Scalar.lookupCustomScalarOrFallbackToString(scalars, sddmNode)
data[k] = SchemaKit.Scalar.applyCodec(scalar.codec.decode, v)
const scalar = Schema.Scalar.lookupCustomScalarOrFallbackToString(scalars, sddmNode)
data[k] = Schema.Scalar.applyCodec(scalar.codec.decode, v)
} else if (SchemaDrivenDataMap.isOutputObject(sddmNode)) {
decodeResultData_({
data: v,
Expand Down
8 changes: 4 additions & 4 deletions src/extensions/CustomScalars/encode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaKit } from '../../entrypoints/schema.js'
import { Schema } from '../../entrypoints/schema.js'
import type { RegisteredScalars } from '../../layers/6_client/fluent.js'
import { Grafaid } from '../../lib/grafaid/__.js'
import { SchemaDrivenDataMap } from '../../types/SchemaDrivenDataMap/__.js'
Expand Down Expand Up @@ -55,13 +55,13 @@ const encodeInputFieldLike = (
*/

if (SchemaDrivenDataMap.isCustomScalarName(sddmNode)) {
const scalar = SchemaKit.Scalar.lookupCustomScalarOrFallbackToString(scalars, sddmNode)
args[argName] = SchemaKit.Scalar.applyCodec(scalar.codec.encode, argValue)
const scalar = Schema.Scalar.lookupCustomScalarOrFallbackToString(scalars, sddmNode)
args[argName] = Schema.Scalar.applyCodec(scalar.codec.encode, argValue)
return
}

if (SchemaDrivenDataMap.isScalar(sddmNode)) {
args[argName] = SchemaKit.Scalar.applyCodec(sddmNode.codec.encode, argValue)
args[argName] = Schema.Scalar.applyCodec(sddmNode.codec.encode, argValue)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default Generator
libraryPaths: {
client: `../../../../entrypoints/client.ts`,
schema: `../../../../entrypoints/schema.ts`,
scalars: `../../../../types/Schema/types/Scalar/scalars.ts`,
scalars: `../../../../types/Schema/types/Scalar/standardScalarTypes.ts`,
utilitiesForGenerated: `../../../../entrypoints/utilities-for-generated.ts`,
},
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as $$Utilities from '../../../../../../entrypoints/utilities-for-generated.js'

export * from '../../../../../../types/Schema/types/Scalar/scalars.js'
export * from '../../../../../../types/Schema/types/Scalar/standardScalarTypes.js'

//
//
Expand All @@ -14,4 +14,4 @@ export * from '../../../../../../types/Schema/types/Scalar/scalars.js'
//
//

export type Date = $$Utilities.SchemaKit.Scalar.ScalarCodecless<'Date'>
export type Date = $$Utilities.Schema.Scalar.ScalarCodecless<'Date'>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SchemaKit as $ } from '../../../../../../entrypoints/utilities-for-generated.js'
import type { Schema as $ } from '../../../../../../entrypoints/utilities-for-generated.js'
import type * as $$Utilities from '../../../../../../entrypoints/utilities-for-generated.js'
import type * as Data from './Data.js'
import type * as MethodsRoot from './MethodsRoot.js'
Expand Down Expand Up @@ -445,9 +445,7 @@ export namespace Schema {
//
//
//
export interface Schema<$Scalars extends $$Utilities.SchemaKit.Scalar.ScalarMap = {}>
extends $$Utilities.SchemaIndexBase
{
export interface Schema<$Scalars extends $$Utilities.Schema.Scalar.ScalarMap = {}> extends $$Utilities.Schema {
name: Data.Name
RootTypesPresent: ['Mutation', 'Query']
RootUnion: Schema.Mutation | Schema.Query
Expand Down
Loading

0 comments on commit c29c877

Please sign in to comment.