MCPcopy Index your code
hub / github.com/webiny/webiny-js / createGraphQLSchema

Function createGraphQLSchema

packages/handler-graphql/src/createGraphQLSchema.ts:32–124  ·  view source on GitHub ↗
(context: Context)

Source from the content-addressed store, hash-verified

30};
31
32export const createGraphQLSchema = async (context: Context) => {
33 GraphQLSchemaComposerFeature.register(context.container);
34
35 const scalars = context.plugins
36 .byType<GraphQLScalarPlugin>("graphql-scalar")
37 .map(item => item.scalar);
38
39 const typeDefs: TypeDefs[] = [
40 gql`
41 type Query
42 type Mutation
43 ${scalars.map(scalar => `scalar ${scalar.name}`).join(" ")}
44 scalar JSON
45 scalar Long
46 scalar Icon
47 scalar RefInput
48 scalar Number
49 scalar Any
50 scalar Date
51 scalar DateTime
52 scalar Time
53
54 type Error {
55 code: String
56 message: String
57 data: JSON
58 stack: String
59 }
60
61 type BooleanResponse {
62 data: Boolean
63 error: Error
64 }
65 `
66 ];
67
68 const resolvers: Resolvers<any>[] = [
69 {
70 ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {
71 acc[s.name] = s;
72 return acc;
73 }, {}),
74 JSON: JsonScalar,
75 Long: LongScalar,
76 RefInput: RefInputScalar,
77 Number: NumberScalar,
78 Any: AnyScalar,
79 DateTime: DateTimeScalar,
80 Date: DateScalar,
81 Time: TimeScalar,
82 Icon: IconScalar
83 }
84 ];
85
86 const resolverDecoration = new ResolverDecoration();
87
88 // Process legacy plugins
89 const plugins = getSchemaPlugins(context);

Callers 1

Calls 11

addDecoratorsMethod · 0.95
decorateResolversMethod · 0.95
getSchemaPluginsFunction · 0.85
byTypeMethod · 0.80
registerMethod · 0.65
mapMethod · 0.65
pushMethod · 0.65
resolveMethod · 0.65
buildMethod · 0.65
joinMethod · 0.45
reduceMethod · 0.45

Tested by

no test coverage detected