Skip to content

Commit

Permalink
Refactor: Replace graphql-type-json with graphql-scalars (#2191)
Browse files Browse the repository at this point in the history
This should be non-breaking, as apps have `graphql-type-json` as
dependency on their own. After merging this, the starter should also
switch to `graphql-scalars`.

---------

Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
  • Loading branch information
dkarnutsch and johnnyomair authored Jun 25, 2024
1 parent caefa1c commit fe22985
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 124 deletions.
16 changes: 16 additions & 0 deletions .changeset/small-eggs-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@comet/cms-api": major
---

API Generator: Replace graphql-type-json with graphql-scalars for JSON columns

**Upgrading**

1. Install graphql-scalars: `npm install graphql-scalars`
2. Uninstall graphql-type-json: `npm install graphql-type-json`
3. Update imports:

```diff
- import { GraphQLJSONObject } from "graphql-type-json";
+ import { GraphQLJSONObject } from "graphql-scalars";
```
1 change: 0 additions & 1 deletion demo/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"faker": "^5.0.0",
"file-type": "^16.0.0",
"graphql": "^15.0.0",
"graphql-type-json": "^0.3.0",
"hasha": "^5.0.0",
"helmet": "^4.6.0",
"image-size": "^0.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/cms-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"get-image-colors": "^4.0.0",
"got": "^11.8.0",
"graphql-parse-resolve-info": "^4.13.0",
"graphql-type-json": "^0.3.2",
"graphql-scalars": "^1.23.0",
"hasha": "^5.2.2",
"jsonwebtoken": "^8.5.1",
"jszip": "^3.10.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/cms-api/src/auth/resolver/auth.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Inject, Type } from "@nestjs/common";
import { Args, Context, Mutation, Parent, Query, ResolveField, Resolver } from "@nestjs/graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";
import { IncomingMessage } from "http";

import { SkipBuild } from "../../builds/skip-build.decorator";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Block } from "@comet/blocks-api";
import { GraphQLScalarType } from "graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

const rootBlockDataScalars = new Map<string, GraphQLScalarType>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Block } from "@comet/blocks-api";
import { GraphQLScalarType } from "graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

const rootBlockInputScalars = new Map<string, GraphQLScalarType>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseEntity, Embedded, Entity, OneToOne, PrimaryKey, Property } from "@mikro-orm/core";
import { Field, ID, Int, ObjectType } from "@nestjs/graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";
import { v4 as uuid } from "uuid";

import { ImageCropArea } from "../../images/entities/image-crop-area.entity";
Expand Down
2 changes: 1 addition & 1 deletion packages/api/cms-api/src/generator/generate-crud-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export async function generateCrudInput(
import { Transform, Type } from "class-transformer";
import { IsString, IsNotEmpty, ValidateNested, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsUUID, IsArray, IsInt } from "class-validator";
import { IsSlug, RootBlockInputScalar, IsNullable, PartialType} from "@comet/cms-api";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";
import { BlockInputInterface, isBlockInputInterface } from "@comet/blocks-api";
${generateImportsCode(imports)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Type } from "@nestjs/common";
import { Field, InputType } from "@nestjs/graphql";
import { Transform } from "class-transformer";
import { IsEnum, IsOptional, ValidateNested, ValidationArguments } from "class-validator";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

import { RedirectGenerationType, RedirectSourceTypeValues } from "../redirects.enum";
import { IsValidRedirectSource } from "../validators/isValidRedirectSource";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block, BlockDataInterface, RootBlock, RootBlockEntity } from "@comet/bl
import { Embedded, Entity, Enum, OptionalProps, PrimaryKey, Property } from "@mikro-orm/core";
import { Type } from "@nestjs/common";
import { Field, ID, ObjectType } from "@nestjs/graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";
import { v4 as uuid } from "uuid";

import { RootBlockType } from "../../blocks/root-block-type";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Field, ObjectType } from "@nestjs/graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

import { ContentScope } from "../interfaces/content-scope.interface";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Field, InputType } from "@nestjs/graphql";
import { IsArray, IsObject } from "class-validator";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

import { ContentScope } from "../interfaces/content-scope.interface";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Field, ID, InputType } from "@nestjs/graphql";
import { IsArray, IsBoolean, IsDate, IsObject, IsOptional, IsString, IsUUID } from "class-validator";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

import { ContentScope } from "../interfaces/content-scope.interface";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseEntity, Entity, PrimaryKey, Property } from "@mikro-orm/core";
import { Field, ID, ObjectType, registerEnumType } from "@nestjs/graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";
import { v4 } from "uuid";

import { ContentScope } from "../interfaces/content-scope.interface";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EntityRepository } from "@mikro-orm/core";
import { InjectRepository } from "@mikro-orm/nestjs";
import { Args, Mutation, Query, Resolver } from "@nestjs/graphql";
import { GraphQLJSONObject } from "graphql-type-json";
import { GraphQLJSONObject } from "graphql-scalars";

import { SkipBuild } from "../builds/skip-build.decorator";
import { RequiredPermission } from "./decorators/required-permission.decorator";
Expand Down
Loading

0 comments on commit fe22985

Please sign in to comment.