Custom scalar in federated subgraph using lambda Apollo server gateway. Can't get argument value in resolver after parseValue correctly transformed my input parameters

I’ve defined a simple custom Date scalar, which is used in one of the subgraphs in a federated graph. I have a query using that custom scalar as an input argument. And I’m using lambda as ApolloServer, by using the apollo-server-lambda package.
The problem I’m facing is:
The argument it’s successfully transformed in the parseLiteral function(The log print out the correct string “1990-01-01”). But when I try to get it from the resolver by calling args.date, it print out a {} instead of the string “1990-01-01”.
Any idea why?

My schema definition:
scalar Date
type Query {
hello(date: Date): String
}

My query:
query{
hello(date:“1990-01-01”)
}

My custom scalar type:
import { format, parseISO } from ‘date-fns’;
import { GraphQLScalarType, Kind } from ‘graphql’;

export const dateScalar = new GraphQLScalarType({
name: ‘Date’,
description: ‘Date custom scalar type’,

serialize(value): string {
try {
return convertToString(value);
} catch (e) {
throw new Error(Failed to convert Date ${value} to string);
}
},

parseValue(value): string {
console.log(parseValue Date: ${value} ${typeof value});
return value as string;
},

parseLiteral(ast) {
console.log(parseLiteral Date: ${ast.kind});
if (ast.kind === Kind.STRING) {
console.log(parseLiteral Date: ${ast.value} ${typeof ast.value});
return ast.value;
}
return null;
},
});

const dateFormat = ‘yyyy-MM-dd’;
const convertToString = (value: unknown): string => {
switch (typeof value) {
case ‘object’:
return format(value as Date, dateFormat);
case ‘string’:
return format(parseISO(value), dateFormat);
default:
return value as string;
}
};

My resolver:
import { QueryResolvers } from ‘…/…/generated/resolvers-types’;

export const hello: QueryResolvers[‘hello’] = (parent, args, context, info) => {
console.log(Resolver args: ${JSON.stringify(args)});
return Hello user(${context.personId}) from PersonClient! ${args.date};
};

Hello! In the future, if you can share a full reproduction that would be helpful. Here’s a codesandbox, I used as much of your code as I could but it’s incomplete so I filled in the gaps. The solution to your problem most likely lies in the bits that I added.

Thanks for replying! That’s almost the same as my code.
The difference is:
I’m using ApolloServer version 3.
And I’m using the corresponding package for lambda in version 3.
import { ApolloServer } from 'apollo-server-lambda';

Are you still encountering the error? Can you share a reproduction? The error you’re seeing should happen in express as well so you can fork my codesandbox if that’s helpful.

Can you make the switch to Apollo Server v4 and use the new lambda integration?
@as-integrations/aws-lambda