-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
// dev.ts: A simple modification of $fresh/dev.ts for GraphQL. | ||
import { ensureDir, walk } from "https://deno.land/[email protected]/fs/mod.ts"; | ||
import { dirname, join } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { | ||
dirname, | ||
join, | ||
parse, | ||
} from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { | ||
fromFileUrl, | ||
toFileUrl, | ||
|
@@ -65,7 +69,12 @@ ${ | |
const manifest = { | ||
modules: { | ||
${modules.map((file, i) => `"${file.slice(1)}": $${i}`).join(",\n ")} | ||
${ | ||
modules.map((file, i) => { | ||
const { dir, name } = parse(file); | ||
return `"${dir.slice(1)}/${name}": $${i}`; | ||
}).join(",\n ") | ||
} | ||
}, | ||
baseUrl: import.meta.url, | ||
}; | ||
|
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 |
---|---|---|
|
@@ -14,28 +14,18 @@ import { sep } from "https://deno.land/[email protected]/path/mod.ts"; | |
|
||
export type Callable = (...args: any[]) => any; | ||
|
||
export type GraphQLModule< | ||
TSource, | ||
TContext, | ||
TArgs = Record<string, any>, | ||
TReturn = any, | ||
> = { | ||
export type GraphQLModule = { | ||
schema?: string; | ||
resolver?: IResolvers | IFieldResolver<TSource, TContext, TArgs, TReturn>; | ||
resolver?: IResolvers | IFieldResolver<any, any, any, any>; | ||
}; | ||
|
||
export type Manifest< | ||
TSource, | ||
TContext, | ||
TArgs = Record<string, any>, | ||
TReturn = any, | ||
> = { | ||
modules: Record<string, GraphQLModule<TSource, TContext, TArgs, TReturn>>; | ||
export type Manifest = { | ||
modules: Record<string, GraphQLModule>; | ||
baseUrl: string; | ||
}; | ||
|
||
export const fromManifest = < | ||
TManifest extends Manifest<any, any, any, any>, | ||
TManifest extends Manifest, | ||
TContext = unknown, | ||
>( | ||
manifest: TManifest, | ||
|
@@ -53,7 +43,7 @@ export const fromManifest = < | |
if (!resolver) return; | ||
|
||
const resolverObj: IResolvers = {}; | ||
const pathSegments = name.split(sep).slice(0, -1); | ||
const pathSegments = name.split(sep); | ||
const isSubscription = pathSegments[0] === "Subscription"; | ||
|
||
let currentPath = resolverObj; | ||
|