INNER CODE UNIT · TypeScript
parseResponse
yarax/swagger-to-graphql · src/index.ts:28
export function parseResponse(response: any, returnType: GraphQLOutputType) {
const nullableType =
returnType instanceof GraphQLNonNull ? returnType.ofType : returnType;
if (
nullableType instanceof GraphQLObjectType ||
nullableType instanceof GraphQLList
) {
return response;
}
if (nullableType.name === 'String' && typeof response !== 'string') {
return JSON.stringify(response);
}
return response;
}
const getFields = <TContext>(