Skip to content

Commit

Permalink
refactor: simplify schema type
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Oct 21, 2024
1 parent 1ad6bfc commit 653210d
Show file tree
Hide file tree
Showing 94 changed files with 1,002 additions and 1,127 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
"default": "./build/entrypoints/schema.js"
}
},
"./schema/scalars": {
"import": {
"default": "./build/entrypoints/scalars.js"
}
},
"./utilities-for-generated": {
"import": {
"default": "./build/entrypoints/utilities-for-generated.js"
Expand Down
2 changes: 1 addition & 1 deletion src/entrypoints/_Graffle.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '../layers/6_client/client.js'
export * as Scalars from './scalars.js'
export * as Scalars from './_Scalars.js'
1 change: 1 addition & 0 deletions src/entrypoints/_Scalars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { create } from '../types/Schema/types/Scalar/_.js'
3 changes: 0 additions & 3 deletions src/entrypoints/scalars.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/entrypoints/schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from '../layers/1_Schema/__.js'
export { Select } from '../layers/2_Select/__.js'
export { InferResult } from '../layers/3_InferResult/__.js'
export * from '../types/Schema/__.js'
2 changes: 1 addition & 1 deletion src/entrypoints/utilities-for-generated.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { type Simplify } from 'type-fest'
export { type Schema as SchemaIndexBase } from '../generator/generators/Schema.js'
export { SchemaKit } from '../layers/1_Schema/__.js'
export * from '../layers/2_Select/__.js'
export { type ClientContext } from '../layers/6_client/fluent.js'
export type {
Expand All @@ -13,4 +12,5 @@ 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 { type SchemaDrivenDataMap } from '../types/SchemaDrivenDataMap/__.js'
5 changes: 2 additions & 3 deletions src/extensions/CustomScalars/decode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Kind } from 'graphql'
import { SchemaKit } from '../../entrypoints/schema.js'
import { applyCodec } from '../../layers/1_Schema/Hybrid/types/Scalar/Scalar.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 @@ -60,10 +59,10 @@ const decodeResultData_ = (input: {
const sddmNode = sddmOutputField.nt

if (SchemaDrivenDataMap.isScalar(sddmNode)) {
data[k] = applyCodec(sddmNode.codec.decode, v)
data[k] = SchemaKit.Scalar.applyCodec(sddmNode.codec.decode, v)
} else if (SchemaDrivenDataMap.isCustomScalarName(sddmNode)) {
const scalar = SchemaKit.Scalar.lookupCustomScalarOrFallbackToString(scalars, sddmNode)
data[k] = applyCodec(scalar.codec.decode, v)
data[k] = SchemaKit.Scalar.applyCodec(scalar.codec.decode, v)
} else if (SchemaDrivenDataMap.isOutputObject(sddmNode)) {
decodeResultData_({
data: v,
Expand Down
5 changes: 2 additions & 3 deletions src/extensions/CustomScalars/encode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SchemaKit } from '../../entrypoints/schema.js'
import { applyCodec } from '../../layers/1_Schema/Hybrid/types/Scalar/Scalar.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 @@ -57,12 +56,12 @@ const encodeInputFieldLike = (

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

if (SchemaDrivenDataMap.isScalar(sddmNode)) {
args[argName] = applyCodec(sddmNode.codec.encode, argValue)
args[argName] = SchemaKit.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: `../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.ts`,
scalars: `../../../../types/Schema/types/Scalar/scalars.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 '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js'
export * from '../../../../../../types/Schema/types/Scalar/scalars.js'

//
//
Expand Down
Loading

0 comments on commit 653210d

Please sign in to comment.