From 495f5b593a3d99f42b5df40613138078f69d3e82 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 8 May 2024 17:13:22 +0300 Subject: [PATCH] astFromValue fails with a custom scalar serializing to an object value --- src/utilities/__tests__/astFromValue-test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utilities/__tests__/astFromValue-test.ts b/src/utilities/__tests__/astFromValue-test.ts index 0f9d474256..195dfc153f 100644 --- a/src/utilities/__tests__/astFromValue-test.ts +++ b/src/utilities/__tests__/astFromValue-test.ts @@ -233,6 +233,24 @@ describe('astFromValue', () => { expect(() => astFromValue('value', returnCustomClassScalar)).to.throw( 'Cannot convert value to AST: {}.', ); + + const returnObjectScalar = new GraphQLScalarType({ + name: 'ReturnObjectScalar', + serialize() { + return { some: 'data' }; + }, + }); + + expect(astFromValue('value', returnObjectScalar)).to.deep.equal({ + kind: 'ObjectValue', + fields: [ + { + kind: 'ObjectField', + name: { kind: 'Name', value: 'some' }, + value: { kind: 'StringValue', value: 'data' }, + }, + ], + }); }); it('does not converts NonNull values to NullValue', () => {