Using apollo-graphql, I've created an "account" type and accompanying resolver that uses graphql-iso-date. The configuration results in the following errors, any ideas on cause and resolution?
In the code included below, typedefs are combined into a collection from specific typedef modules.
Type '{ Date: GraphQLScalarType; DateTime: GraphQLScalarType; Time: GraphQLScalarType; } | { Query: AccountQueryResolver; }' is not assignable to type 'IResolvers | IResolvers[] | undefined'.
Type '{ Date: GraphQLScalarType; DateTime: GraphQLScalarType; Time: GraphQLScalarType; }' is not assignable to type 'IResolvers | IResolvers[] | undefined'.
Type '{ Date: GraphQLScalarType; DateTime: GraphQLScalarType; Time: GraphQLScalarType; }' is not assignable to type 'IResolvers'. Property 'Date' is incompatible with index signature
Type 'GraphQLScalarType' is not assignable to type '(() => any) | GraphQLScalarType | IEnumResolver | IResolverObject | IResolverOptions'.
Type 'GraphQLScalarType' is not assignable to type 'IResolverObject'.
Index signature is missing in type 'GraphQLScalarType'.
TypeDefs Collection
import CustomScalarTypeDefs from "./custom";
import QueryTypeDefs from "./query";
import AccountTypeDefs from "./account";
const TypeDefs = [CustomScalarTypeDefs, QueryTypeDefs, AccountTypeDefs];
export default TypeDefs;
Custom Scalar TypeDefs
import { gql } from "apollo-server-express";
const customScalarTypeDefs = gql`
scalar Date
scalar DateTime
scalar Time
`;
export default customScalarTypeDefs;
Query TypeDefs
import { gql } from "apollo-server-express";
const QueryTypeDefs = gql`
type Query {
account(id: String!): Account
}
`;
export default QueryTypeDefs;
Custom Scalar Resolver
import { GraphQLDate, GraphQLDateTime, GraphQLTime } from "graphql-iso-date";
const CustomScalarResolver = {
Date: GraphQLDate,
DateTime: GraphQLDateTime,
Time: GraphQLTime
};
export default CustomScalarResolver;
Account Resolver
import { QueryById } from "./signatures";
import Account, { AccountModel, AccountPayload } from "../../models/account";
interface AccountQueryResolver {
account: (_: never, req: QueryById) => Promise<AccountModel | null>;
createAccount: (
parent: Account | null,
{ entity, name }: AccountPayload
) => Promise<AccountModel | null>;
}
const accountResolver: AccountQueryResolver = {
account: (_, { id }): Promise<AccountModel | null> => {
return Account.findOne({ _id: id }).exec();
},
createAccount: (_, { entity, name }): Promise<AccountModel | null> => {
return Account.create({ entity, name });
}
};
export default accountResolver;