Skip to content

Commit

Permalink
chore(website): make extensions a top level section
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Oct 22, 2024
1 parent a3521fb commit 53abb1c
Show file tree
Hide file tree
Showing 29 changed files with 65 additions and 50 deletions.
53 changes: 24 additions & 29 deletions src/documentBuilder/InferResult/OutputObject.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
import type { Simplify } from 'type-fest'
import { type StringKeyof } from '../../lib/prelude.js'
import type { StringKeyof } from '../../lib/prelude.js'
import type { TSErrorDescriptive } from '../../lib/ts-error.js'
import type { Schema } from '../../types/Schema/__.js'
import type { Select } from '../Select/__.js'
import type { Alias } from './Alias.js'
import type { OutputField } from './OutputField.js'
import type { ScalarsWildcard } from './ScalarsWildcard.js'

// dprint-ignore
export type Object<$SelectionSet, $Schema extends Schema, $Node extends Schema.OutputObject> =
Select.SelectScalarsWildcard.IsSelectScalarsWildcard<$SelectionSet> extends true
// todo what about when scalars wildcard is combined with other fields like relations?
? ScalarsWildcard<$SelectionSet, $Schema,$Node>
:
Simplify<
& SelectionNonSelectAlias<$SelectionSet, $Schema, $Node>
& Alias<$Schema, $Node, $SelectionSet>
>
? ScalarsWildcard<$SelectionSet, $Schema, $Node>
: Simplify<
& SelectionNonSelectAlias<$SelectionSet, $Schema, $Node>
& Alias<$Schema, $Node, $SelectionSet>
>

// dprint-ignore
type SelectionNonSelectAlias<$SelectionSet , $Schema extends Schema, $SchemaNode extends Schema.OutputObject> =
{
[$Key in PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet>]:
$Key extends keyof $SchemaNode['fields']
? OutputField<$SelectionSet[$Key], $SchemaNode['fields'][$Key], $Schema>
: Errors.UnknownFieldName<$Key, $SchemaNode>
}
type SelectionNonSelectAlias<$SelectionSet, $Schema extends Schema, $Node extends Schema.OutputObject> = {
[$Key in PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet>]: $Key extends keyof $Node['fields']
? OutputField<$SelectionSet[$Key], $Node['fields'][$Key], $Schema>
: Errors.UnknownFieldName<$Key, $Node>
}

// dprint-ignore
export namespace Errors {
export type UnknownFieldName<$FieldName extends string, $Object extends Schema.StandardTypes.RootType | Schema.OutputObject> =
TSErrorDescriptive<'Object', `field "${$FieldName}" does not exist on object "${$Object['name']}"`>
export type UnknownFieldName<
$FieldName extends string,
$Object extends Schema.StandardTypes.RootType | Schema.OutputObject,
> = TSErrorDescriptive<'Object', `field "${$FieldName}" does not exist on object "${$Object['name']}"`>
}

// dprint-ignore
export type PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet> = StringKeyof<{
[
$FieldName in keyof $SelectionSet as $SelectionSet[$FieldName] extends Select.Indicator.Negative
? never
: $SelectionSet[$FieldName] extends any[]
? never
: $FieldName
]: 0
}>
export type PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet> = StringKeyof<
{
[
$FieldName in keyof $SelectionSet as $SelectionSet[$FieldName] extends Select.Indicator.Negative ? never
: $SelectionSet[$FieldName] extends any[] ? never
: $FieldName
]: 0
}
>
12 changes: 12 additions & 0 deletions website/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ const sidebars = fixLinks(generateSidebar([
useTitleFromFileHeading: true,
keepMarkdownSyntaxFromTitle: true,
},
{
hyphenToSpace: true,
capitalizeEachWords: true,
scanStartPath: 'content/extensions',
resolvePath: '/extensions/',
prefixSeparator: '_',
removePrefixAfterOrdering: true,
useTitleFromFrontmatter: true,
useTitleFromFileHeading: true,
keepMarkdownSyntaxFromTitle: true,
},
]) as SidebarMulti)

sidebars['/examples/'].items.find(_ => _.text === 'About')!.items!.unshift({ text: 'Introduction', link: '/' })
Expand Down Expand Up @@ -128,6 +139,7 @@ export default defineConfig({
nav: [
{ text: 'Guides', link: '/guides' },
{ text: 'Examples', link: '/examples' },
{ text: 'Extensions', link: '/extensions' },
],
sidebar: {
...sidebars,
Expand Down
5 changes: 5 additions & 0 deletions website/content/extensions/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Extensions

Welcome to Graffle's collection of extensions.

TODO
1 change: 1 addition & 0 deletions website/content/extensions/introspection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!--@include: @../../src/extensions/Introspection/documentation.md-->
1 change: 1 addition & 0 deletions website/content/extensions/opentelemetry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!--@include: @/../../src/extensions/Opentelemetry/documentation.md-->
1 change: 1 addition & 0 deletions website/content/extensions/schema-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!--@include: @/../../src/extensions/schemaErrors/documentation.md-->
1 change: 1 addition & 0 deletions website/content/extensions/throws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!--@include: @/../../src/extensions/Throws/documentation.md-->
3 changes: 3 additions & 0 deletions website/content/extensions/upload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!--@include: @/../../src/extensions/Upload/documentation.md-->

test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# GraphQL Feature Mapping

## Aliases

## Arguments

## Custom Scalars

## Directives

## Enums

## Inline Fragments

### Field Groups

### Type Conditions
File renamed without changes.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion website/content/guides/40_graphql-feature-mapping/enums.md

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions website/content/guides/40_graphql-feature-mapping/unions.md

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion website/content/guides/60_extensions/introspection.md

This file was deleted.

1 change: 0 additions & 1 deletion website/content/guides/60_extensions/opentelemetry.md

This file was deleted.

1 change: 0 additions & 1 deletion website/content/guides/60_extensions/schema-errors.md

This file was deleted.

1 change: 0 additions & 1 deletion website/content/guides/60_extensions/throws.md

This file was deleted.

1 change: 0 additions & 1 deletion website/content/guides/60_extensions/upload.md

This file was deleted.

0 comments on commit 53abb1c

Please sign in to comment.