-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api-serverless-cms): base tests (#4332)
- Loading branch information
1 parent
2035c6f
commit a11bb5b
Showing
31 changed files
with
1,362 additions
and
24 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
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
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
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,8 +1,9 @@ | ||
import { Plugin } from "@webiny/plugins/types"; | ||
import { createSystemSchemaPlugin } from "./system"; | ||
import { graphQLHandlerFactory, GraphQLHandlerFactoryParams } from "./graphQLHandlerFactory"; | ||
import { createBaseSchema } from "~/graphql/schema/baseSchema"; | ||
|
||
export type CreateGraphQLParams = GraphQLHandlerFactoryParams; | ||
export const createGraphQL = (params: CreateGraphQLParams) => { | ||
return [createBaseSchema(), createSystemSchemaPlugin(), graphQLHandlerFactory(params)]; | ||
export const createGraphQL = (params: CreateGraphQLParams): Plugin[] => { | ||
return [createBaseSchema(), createSystemSchemaPlugin(), ...graphQLHandlerFactory(params)]; | ||
}; |
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
63 changes: 63 additions & 0 deletions
63
packages/api-serverless-cms/__tests__/handlers/graphQlHandler.ts
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { createHandler } from "@webiny/handler-aws"; | ||
import { createInvoke } from "./helpers/invoke"; | ||
import { createLambdaContext } from "./helpers/lambdaContext"; | ||
import { Plugin } from "@webiny/plugins/types"; | ||
import { createCore } from "./helpers/core"; | ||
import { PathType } from "./types"; | ||
import { getIntrospectionQuery } from "graphql"; | ||
import { createGraphQl } from "./graphql"; | ||
import { createQueryFactory } from "~tests/handlers/helpers/factory"; | ||
import { createMutationFactory } from "~tests/handlers/helpers/factory/mutation"; | ||
|
||
export interface IGraphQlHandlerParams { | ||
path: PathType; | ||
plugins?: Plugin[]; | ||
features?: boolean | string[]; | ||
} | ||
|
||
export const useGraphQlHandler = (params: IGraphQlHandlerParams) => { | ||
const core = createCore({ | ||
...params | ||
}); | ||
|
||
const handler = createHandler({ | ||
plugins: core.plugins, | ||
debug: process.env.DEBUG === "true" | ||
}); | ||
|
||
const invoke = createInvoke({ | ||
handler, | ||
path: params.path, | ||
lambdaContext: createLambdaContext() | ||
}); | ||
|
||
const createQuery = createQueryFactory({ | ||
invoke | ||
}); | ||
const createMutation = createMutationFactory({ | ||
invoke | ||
}); | ||
|
||
return { | ||
invoke, | ||
async introspect() { | ||
return invoke({ | ||
body: { | ||
query: getIntrospectionQuery() | ||
} | ||
}); | ||
}, | ||
handler, | ||
cmsStorage: core.cmsStorage, | ||
i18nStorage: core.i18nStorage, | ||
pageBuilderStorage: core.pageBuilderStorage, | ||
fileManagerStorage: core.fileManagerStorage, | ||
securityStorage: core.securityStorage, | ||
tenancyStorage: core.tenancyStorage, | ||
login: core.login, | ||
...createGraphQl({ | ||
createQuery, | ||
createMutation | ||
}) | ||
}; | ||
}; |
13 changes: 13 additions & 0 deletions
13
packages/api-serverless-cms/__tests__/handlers/graphql/index.ts
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createInstallGraphQL } from "./install"; | ||
import { ICreateMutationCb, ICreateQueryCb } from "~tests/handlers/helpers/factory/types"; | ||
|
||
export interface ICreateGraphQlParams { | ||
createQuery: ICreateQueryCb; | ||
createMutation: ICreateMutationCb; | ||
} | ||
|
||
export const createGraphQl = (params: ICreateGraphQlParams) => { | ||
return { | ||
...createInstallGraphQL(params) | ||
}; | ||
}; |
Oops, something went wrong.