parseLiteral(ast) { if (ast.kind === _graphql.Kind.STRING) { return { __type: 'Date', iso: parseDateIsoLiteral(ast) }; } else if (ast.kind === _graphql.Kind.OBJECT) { const __type = ast.fields.find(field => field.name.value === '__type'); const iso = ast.fields.find(field => field.name.value === 'iso'); if (__type && __type.value && __type.value.value === 'Date' && iso) { return { __type: __type.value.value, iso: parseDateIsoLiteral(iso.value) }; } } throw new TypeValidationError(ast.kind, 'Date'); }
parseLiteral(ast) { if (ast.kind === _graphql.Kind.STRING) { return parseFileValue(ast.value); } else if (ast.kind === _graphql.Kind.OBJECT) { const __type = ast.fields.find(field => field.name.value === '__type'); const name = ast.fields.find(field => field.name.value === 'name'); const url = ast.fields.find(field => field.name.value === 'url'); if (__type && __type.value && name && name.value) { return parseFileValue({ __type: __type.value.value, name: name.value.value, url: url && url.value ? url.value.value : undefined }); } } throw new TypeValidationError(ast.kind, 'File'); }
parseLiteral(ast) { if (ast.kind === _graphql.Kind.STRING) { return { __type: 'Bytes', base64: ast.value }; } else if (ast.kind === _graphql.Kind.OBJECT) { const __type = ast.fields.find(field => field.name.value === '__type'); const base64 = ast.fields.find(field => field.name.value === 'base64'); if (__type && __type.value && __type.value.value === 'Bytes' && base64 && base64.value && typeof base64.value.value === 'string') { return { __type: __type.value.value, base64: base64.value.value }; } } throw new TypeValidationError(ast.kind, 'Bytes'); }
parseLiteral(ast) { if (ast.kind === Kind.INT) { return new Date(parseInt(ast.value, 10)) } return null }
parseLiteral(ast) { if (ast.kind !== Kind.STRING || !ast.value.match(/^\d{4}-\d{2}-\d{2}$/)) { throw new Error('Invalid date format'); } const date = new Date(ast.value); if (date.toString() === 'Invalid Date') { throw new Error('Invalid Date'); } return date; }
parseLiteral (ast) { if (ast.kind === Kind.STRING) { return dateParse(ast.value + ' 12 Z') } return null }
parseLiteral(ast) { if (ast.kind === Kind.INT) { return parseInt(ast.value, 10); } return null; }
parseLiteral (ast) { if (ast.kind === Kind.STRING) { return new Date(ast.value) } return null }
parseLiteral (ast) { if (ast.kind === Kind.STRING) { return new Date(ast.value) } return null }
parseLiteral (ast) { if (ast.kind === Kind.STRING) { return new Date(`${ast.value}-01`) } return null }
parseLiteral(ast) { if (ast.kind !== Kind.STRING || !ast.value.match(/^\d{4}-\d{2}-\d{2}$/)) { throw new Error('Invalid date format'); } const date = new Date(ast.value); if (date.toString() === 'Invalid Date') { throw new Error('Invalid Date'); } return date; }