este / este

This repo is suspended.
https://typescript.fun/
MIT License
5.38k stars 512 forks source link

Add graphql-scalars #1698

Closed steida closed 5 years ago

steida commented 5 years ago

https://github.com/okgrow/graphql-scalars

Integration to Nexus is 👌

steida commented 5 years ago

Add

export const GQLMax140Chars = asNexusMethod(
  new RegularExpression('Max140Chars', /[\s\S]{0,140}/),
  'max140Chars',
);

export const GQLMax1024Chars = asNexusMethod(
  new RegularExpression('Max1024Chars', /[\s\S]{0,1024}/),
  'Max1024Chars',
);
steida commented 5 years ago

Ups. Relay does not support custom scalars mapping. That's bad.

https://github.com/facebook/relay/issues/2518

steida commented 5 years ago

But we can fix 'any' type generated with Relay manually via mapped types. OK, that's good enough. API integrity is the must.

steida commented 5 years ago

But Nexus has the same problem. It generates any type for any custom scalar. That sucks. OK, use default scalars until both Nexus and Relay will support custom scalar TS types generation.

steida commented 5 years ago

Oh, Nexus supports custom mapping.

typegenAutoConfig: {
    // debug: true,
    sources: [{ source: path.join(__dirname, './types.ts'), alias: 'types' }],
    contextType: 'types.Context',
    backingTypeMap: {
      EmailAddress: 'string',
    },
  },
steida commented 5 years ago

Hmm, but Relay does not support it yet and useMutation leverages types for input component fields.

https://github.com/facebook/relay/issues/2718

steida commented 5 years ago

But we can patch it!

Low priority, but having restricted GraphQL types would be nice.

steida commented 5 years ago

Sunsetting.