exogee-technology / graphweaver

Turn multiple data sources into a single GraphQL API
https://graphweaver.com
Other
491 stars 18 forks source link

Importing `Date` fields don't work at runtime #1354

Open thekevinbrown opened 6 hours ago

thekevinbrown commented 6 hours ago

Describe the bug When I define an entity with a Date field, I get this error at runtime:

Error: Could not map TypeScript type function Date() { [native code] } to a GraphQL scalar.
    at graphQLScalarForTypeScriptType ([project directory]/node_modules/.pnpm/@exogee+graphweaver@2.8.1_encoding@0.1.13/node_modules/@exogee/graphweaver/lib/schema-builder.js:185:13)

To Reproduce Steps to reproduce the behavior:

CREATE TABLE reproduction (
    id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    test_field date NOT NULL
);

Run import.

Observe on run.

Expected behavior Expected Date to be sanely translated to a scalar, or failing that, at least the imported code to work correctly.

Actual behavior Error

thekevinbrown commented 6 hours ago

Note: If anyone else is hitting this, you can work around it by:

import { DateScalar } from '@exogee/graphweaver-scalars';

Then update the field(s) in question to use () => DateScalar as their type instead of () => Date.