Skip to content

Commit

Permalink
Use GraphQLDateTimeISO from graphql-scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed May 29, 2023
1 parent 5bbf601 commit 38b9555
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- **Breaking Change**: `validate` option of `buildSchema` doesn't accept anymore a custom validation function - use `validateFn` option instead
- **Breaking Change**: removed `dateScalarMode` option from `buildSchema`
- **Breaking Change**: make `graphql-scalars` package a peer dependency and use date scalars from it instead of custom ones
- **Breaking Change**: exported `GraphQLISODateTime` scalar has now a name `DateTimeISO`
- support class-based auth checker, which allows for dependency injection
- allow defining directives for interface types and theirs fields, with inheritance for object types fields (#744)
- allow deprecating input fields and args (#794)
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"peerDependencies": {
"class-validator": ">=0.14.0",
"graphql": "^16.6.0",
"graphql-scalars": "^1.22.0"
"graphql-scalars": "^1.22.1"
},
"peerDependenciesMeta": {
"class-validator": {
Expand Down Expand Up @@ -61,7 +61,7 @@
"dotenv": "^16.0.3",
"graphql": "^16.6.0",
"graphql-redis-subscriptions": "^2.6.0",
"graphql-scalars": "^1.22.0",
"graphql-scalars": "^1.22.1",
"graphql-tag": "^2.12.6",
"graphql-ws": "^5.12.1",
"husky": "^4.3.8",
Expand Down
14 changes: 0 additions & 14 deletions src/scalars/GraphQLISODateTime.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/scalars/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./aliases";
export { default as GraphQLISODateTime } from "./GraphQLISODateTime";
export { GraphQLTimestamp } from "graphql-scalars";
export { GraphQLTimestamp, GraphQLDateTimeISO as GraphQLISODateTime } from "graphql-scalars";
2 changes: 1 addition & 1 deletion tests/functional/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,6 @@ describe("Fields - schema", () => {

expect(overwrittenArrayScalarFieldType.kind).toEqual(TypeKind.NON_NULL);
expect(overwrittenArrayScalarFieldInnerType.kind).toEqual(TypeKind.SCALAR);
expect(overwrittenArrayScalarFieldInnerType.name).toEqual("DateTime");
expect(overwrittenArrayScalarFieldInnerType.name).toEqual("DateTimeISO");
});
});
2 changes: 1 addition & 1 deletion tests/functional/generic-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ describe("Generic types", () => {
expect(friendshipEdgeNodeFieldType.kind).toBe(TypeKind.OBJECT);
expect(friendshipEdgeNodeFieldType.name).toBe("User");
expect(friendshipEdgeFriendedAtFieldType.kind).toBe(TypeKind.SCALAR);
expect(friendshipEdgeFriendedAtFieldType.name).toBe("DateTime");
expect(friendshipEdgeFriendedAtFieldType.name).toBe("DateTimeISO");
});

it("should return child classes data from queries", async () => {
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/scalars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,21 @@ describe("Scalars", () => {
const explicitDateFieldType = getFieldType("explicitDateField");

expect(explicitDateFieldType.kind).toEqual(TypeKind.SCALAR);
expect(explicitDateFieldType.name).toEqual("DateTime");
expect(explicitDateFieldType.name).toEqual("DateTimeISO");
});

it("should generate Date scalar field type when prop type is Date", async () => {
const implicitStringFieldType = getFieldType("implicitDateField");

expect(implicitStringFieldType.kind).toEqual(TypeKind.SCALAR);
expect(implicitStringFieldType.name).toEqual("DateTime");
expect(implicitStringFieldType.name).toEqual("DateTimeISO");
});

it("should generate ISODate scalar field type", async () => {
const ISODateFieldType = getFieldType("ISODateField");

expect(ISODateFieldType.kind).toEqual(TypeKind.SCALAR);
expect(ISODateFieldType.name).toEqual("DateTime");
expect(ISODateFieldType.name).toEqual("DateTimeISO");
});

it("should generate Timestamp scalar field type", async () => {
Expand Down Expand Up @@ -278,7 +278,7 @@ describe("Scalars", () => {
const dateFieldType = getSampleObjectFieldType(schemaInfo.schemaIntrospection)("dateField");

expect(dateFieldType.kind).toEqual(TypeKind.SCALAR);
expect(dateFieldType.name).toEqual("DateTime");
expect(dateFieldType.name).toEqual("DateTimeISO");
});

it("should generate DateTime scalar field type when scalarsMap is using GraphQLISODateTime", async () => {
Expand All @@ -289,7 +289,7 @@ describe("Scalars", () => {
const dateFieldType = getSampleObjectFieldType(schemaInfo.schemaIntrospection)("dateField");

expect(dateFieldType.kind).toEqual(TypeKind.SCALAR);
expect(dateFieldType.name).toEqual("DateTime");
expect(dateFieldType.name).toEqual("DateTimeISO");
});

it("should generate Timestamp scalar field type when scalarsMap is using GraphQLTimestamp", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/typedefs-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe("typeDefs and resolvers", () => {

it("should emit Date scalar", async () => {
const dateScalar = schemaIntrospection.types.find(
it => it.name === "DateTime",
it => it.name === "DateTimeISO",
) as IntrospectionScalarType;

expect(dateScalar.kind).toBe(TypeKind.SCALAR);
Expand Down

0 comments on commit 38b9555

Please sign in to comment.