| 
									
										
										
										
											2022-02-28 16:35:25 +01:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-02 11:45:59 +02:00
										 |  |  | const { GraphQLDate } = require('graphql-scalars'); | 
					
						
							| 
									
										
										
										
											2022-02-28 16:35:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 23:33:39 +02:00
										 |  |  | const parseAndCast = | 
					
						
							|  |  |  |   (parseFn) => | 
					
						
							|  |  |  |   (...args) => { | 
					
						
							|  |  |  |     const parsedValue = parseFn(...args); | 
					
						
							| 
									
										
										
										
											2022-02-28 16:35:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 23:33:39 +02:00
										 |  |  |     if (parsedValue instanceof Date) { | 
					
						
							|  |  |  |       return parsedValue.toISOString().split('T')[0]; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-28 16:35:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 23:33:39 +02:00
										 |  |  |     return parsedValue; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2022-02-28 16:35:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | // GraphQLDate casts the date string to new Date, we want to keep it as a string so we cast it back to a string
 | 
					
						
							|  |  |  | // see https://github.com/excitement-engineer/graphql-iso-date/issues/106
 | 
					
						
							|  |  |  | GraphQLDate.parseValue = parseAndCast(GraphQLDate.parseValue); | 
					
						
							|  |  |  | GraphQLDate.parseLiteral = parseAndCast(GraphQLDate.parseLiteral); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = GraphQLDate; |