File tree Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { ServerContext } from "@fab/runtime" ;
2
+ import { ContextValueMaker } from "@glenstack/cf-workers-graphql" ;
3
+
4
+ export type Context = {
5
+ version : string ;
6
+ } ;
7
+
8
+ export const makeContextValueMaker = ( {
9
+ bundle_id,
10
+ } : ServerContext ) : ContextValueMaker => async (
11
+ request : Request
12
+ ) : Promise < Context > => ( {
13
+ version : bundle_id ,
14
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import { FABRuntime } from "@fab/core" ;
2
2
import { makeGraphQLHandler } from "@glenstack/cf-workers-graphql" ;
3
+ import { makeContextValueMaker } from "./context" ;
3
4
import { schema } from "./schema/index" ;
4
5
import { voyager } from "./voyager" ;
5
6
6
- const graphQLHandler = makeGraphQLHandler ( schema ) ;
7
+ export default function graphql ( { Router, ServerContext } : FABRuntime ) {
8
+ const graphQLHandler = makeGraphQLHandler ( schema , {
9
+ makeContextValue : makeContextValueMaker ( ServerContext ) ,
10
+ } ) ;
7
11
8
- export default function graphql ( { Router } : FABRuntime ) {
9
12
Router . on ( "/graphql" , ( { request } ) => graphQLHandler ( request ) ) ;
10
13
Router . on (
11
14
"/voyager" ,
Original file line number Diff line number Diff line change 8
8
typeDefs as searchResultTypeDefs ,
9
9
resolvers as searchResultResolvers ,
10
10
} from "./types/searchResult" ;
11
+ import { typeDefs as suggestStringTypeDefs } from "./types/suggestString" ;
11
12
12
13
const typeDefs = gql `
13
14
type Query {
@@ -29,6 +30,7 @@ export const schema = makeExecutableSchema({
29
30
externalSourceTypeDefs ,
30
31
documentTypeDefs ,
31
32
searchResultTypeDefs ,
33
+ suggestStringTypeDefs ,
32
34
] ,
33
35
resolvers : [ resolvers , searchResultResolvers ] ,
34
36
} ) ;
Original file line number Diff line number Diff line change
1
+ import gql from "graphql-tag" ;
2
+
3
+ export const typeDefs = gql `
4
+ extend type Query {
5
+ suggestString(queryString: String!): [String!]!
6
+ }
7
+ ` ;
Original file line number Diff line number Diff line change 21
21
// allowing for many production-specific optimisations. See https://fab.dev/kb/production
22
22
// Example setting:
23
23
// API_URL: 'https://api.example.com/graphql'
24
+ ENV : "production" ,
25
+ } ,
26
+ staging : {
27
+ ENV : "staging" ,
24
28
} ,
25
29
} ,
26
30
deploy : {
You can’t perform that action at this time.
0 commit comments