import { astFromValue, print } from 'graphql'; import React, { FC, memo } from 'react'; import { GraphQLFieldWithParentName } from './graph-ql-types'; interface Props { field: GraphQLFieldWithParentName; } export const GraphQLDefaultValue: FC = memo(({ field }) => { // Make Flow happy :/ const fieldO: Record = field; if ('defaultValue' in fieldO && fieldO.defaultValue !== undefined) { const ast = astFromValue(fieldO.defaultValue, fieldO.type); const strDefault = ast ? print(ast) : ''; return {` = ${strDefault}`}; } else { return null; } }); GraphQLDefaultValue.displayName = 'GraphQLDefaultValue';