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 11import { FABRuntime } from "@fab/core" ;
22import { makeGraphQLHandler } from "@glenstack/cf-workers-graphql" ;
3+ import { makeContextValueMaker } from "./context" ;
34import { schema } from "./schema/index" ;
45import { voyager } from "./voyager" ;
56
6- const graphQLHandler = makeGraphQLHandler ( schema ) ;
7+ export default function graphql ( { Router, ServerContext } : FABRuntime ) {
8+ const graphQLHandler = makeGraphQLHandler ( schema , {
9+ makeContextValue : makeContextValueMaker ( ServerContext ) ,
10+ } ) ;
711
8- export default function graphql ( { Router } : FABRuntime ) {
912 Router . on ( "/graphql" , ( { request } ) => graphQLHandler ( request ) ) ;
1013 Router . on (
1114 "/voyager" ,
Original file line number Diff line number Diff line change 88 typeDefs as searchResultTypeDefs ,
99 resolvers as searchResultResolvers ,
1010} from "./types/searchResult" ;
11+ import { typeDefs as suggestStringTypeDefs } from "./types/suggestString" ;
1112
1213const typeDefs = gql `
1314 type Query {
@@ -29,6 +30,7 @@ export const schema = makeExecutableSchema({
2930 externalSourceTypeDefs ,
3031 documentTypeDefs ,
3132 searchResultTypeDefs ,
33+ suggestStringTypeDefs ,
3234 ] ,
3335 resolvers : [ resolvers , searchResultResolvers ] ,
3436} ) ;
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 2121 // allowing for many production-specific optimisations. See https://fab.dev/kb/production
2222 // Example setting:
2323 // API_URL: 'https://api.example.com/graphql'
24+ ENV : "production" ,
25+ } ,
26+ staging : {
27+ ENV : "staging" ,
2428 } ,
2529 } ,
2630 deploy : {
You can’t perform that action at this time.
0 commit comments