Forbid inlining smart tag
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 625
- Avg merge
- 5h 23m
- Merged PRs (30d)
- 24
Description
```ts
import { makeWrapPlansPlugin } from "postgraphile/utils";
const ForbidInliningSmartTagPlugin = makeWrapPlansPlugin(
(context, build) => {
if (
!context.scope.isPgFieldConnection &&
!context.scope.isPgFieldSimpleCollection &&
!context.scope.isPgManyRelationConnectionField &&
!context.scope.isPgManyRelationListField &&
!context.scope.isPgSingleRelationField &&
!context.scope.isPgRowByUniqueConstraintField
) {
return null;
}
if (context.scope.pgCodec?.extensions?.tags?.forbidInlining) {
const {
grafast: { __ListTransformStep },
dataplanPg: { PgSelectSingleStep, PgSelectStep },
EXPORTABLE,
} = build;
return EXPORTABLE(
(__ListTransformStep, PgSelectSingleStep, PgSelectStep) =>
function forbidInlining(step: T): T {
let s: Step = step;
if (s instanceof __ListTransformStep) s = s.getListStep();
if (s instanceof PgSelectSingleStep) s = s.getClassStep();
if (s instanceof PgSelectStep) s.setInliningForbidden();
return step;
},
[__ListTransformStep, PgSelectSingleStep, PgSelectStep]
);
}
return null;
},
(forbidInlining) => (plan) => forbidInlining(plan())
);
```
To use it just add it to your `plugins: [...]` list in your config, and then apply the `@forbidInlining` smart tag to your table/view:
```sql
COMMENT ON VIEW app_public.objects IS $$
@forbidInlining
$$;
```
Ref https://github.com/graphile/crystal/issues/2564
Contributor guide
Assessment
This issue has not been assessed yet.