[ ] Regression
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
I do them as is your tutorial says:
https://docs.nestjs.com/graphql/scalars
But I can not find a way to import them into a .graphql file so I could use it within that file. and since the file is .graphql the import does not work. Missing explain how to import a custom scalar to be used within a .graphql file.
I propose that we use your own example:
https://github.com/nestjs/nest/tree/master/sample/12-graphql-apollo
In your example you expose that you have a module called cats, where inside the module you have your cats.resolvers.ts and your cats.graphql; and on the other hand, you have your date.scalar.ts defined. The question using this example:
What should we do to use the DateScalar in a property of cats.graphql?
Nest version: X.Y.Z
For Tooling issues:
- Node version: XX
- Platform:
Others:
I had that problem and solved it in the following way:
import { Module } from '@nestjs/common';
import { DateScalar } from './scalars/date.scalar';
@Module({
providers: [DateScalar],
exports: [DateScalar]
})
export class CommonModule {}
Later, I imported the common module to a cats module so that the DateScalar is available throughout the cats' module.
And finally I established the following line inside cats.graphql:
scalar Date
type Cat {
id: Int
name: String
age: Int
birthday: Date
}
Put attention that the Scale Date value within the cats.graphql file must match the value set in @Scalar ('Date') in the date.scalar.ts file
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I had that problem and solved it in the following way:
Later, I imported the common module to a cats module so that the DateScalar is available throughout the cats' module.
And finally I established the following line inside cats.graphql:
Put attention that the
Scale Datevalue within the cats.graphql file must match the value set in@Scalar ('Date')in the date.scalar.ts file