Skip to content

Commit ecbd109

Browse files
authored
Export more helpers/types from Grafserv (#461)
2 parents b8da642 + 954438f commit ecbd109

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

.changeset/sweet-singers-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"grafserv": patch
3+
---
4+
5+
Export `getBodyFromFrameworkBody` helper, and a number of types.

grafast/grafserv/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,35 @@ export {
44
GrafservBase,
55
} from "./core/base.js";
66
export type {
7+
BufferResult,
8+
BufferStreamResult,
9+
ErrorResult,
10+
EventStreamHeandlerResult,
711
GrafservBody,
812
GrafservBodyBuffer,
913
GrafservBodyJSON,
1014
GrafservBodyText,
1115
GrafservConfig,
16+
GraphQLHandlerResult,
17+
GraphQLIncrementalHandlerResult,
18+
HandlerResult,
19+
HTMLHandlerResult,
20+
JSONObject,
21+
JSONResult,
22+
JSONValue,
23+
NoContentHandlerResult,
24+
NoContentResult,
1225
NormalizedRequestDigest,
1326
ParsedGraphQLBody,
1427
ProcessGraphQLRequestBodyEvent,
1528
RequestDigest,
29+
Result,
30+
TextHandlerResult,
1631
ValidatedGraphQLBody,
1732
} from "./interfaces.js";
1833
export { DEFAULT_ALLOWED_REQUEST_CONTENT_TYPES } from "./middleware/graphql.js";
1934
export {
35+
getBodyFromFrameworkBody,
2036
getBodyFromRequest,
2137
handleErrors,
2238
httpError,

grafast/grafserv/src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ export function getBodyFromRequest(
107107
});
108108
}
109109

110+
/**
111+
* Using this is a hack, it sniffs the data and tries to determine the type.
112+
* Really you should ask your framework of choice what type of data it has given
113+
* you.
114+
*/
110115
export function getBodyFromFrameworkBody(body: unknown): GrafservBody {
111116
if (typeof body === "string") {
112117
return {
@@ -125,7 +130,7 @@ export function getBodyFromFrameworkBody(body: unknown): GrafservBody {
125130
};
126131
} else {
127132
throw new Error(
128-
`Grafserv Express adaptor doesn't know how to interpret this request body`,
133+
`Grafserv adaptor doesn't know how to interpret this request body`,
129134
);
130135
}
131136
}

postgraphile/website/postgraphile/make-extend-schema-plugin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ import { withPgClientTransaction } from "postgraphile/@dataplan/pg";
499499
export const MyRegisterUserMutationPlugin = makeExtendSchemaPlugin((build) => {
500500
const { sql } = build;
501501
const { users } = build.input.pgRegistry.pgResources;
502+
const { executor } = users;
502503
return {
503504
typeDefs: gql`
504505
input RegisterUserInput {

0 commit comments

Comments
 (0)