UnlyEd/ra-data-graphql-prisma

View on GitHub
src/utils/isRequired.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { IntrospectionListTypeRef, IntrospectionTypeRef, TypeKind } from 'graphql';

const isRequired = (type: IntrospectionTypeRef): boolean => {
  if (type.kind === TypeKind.LIST) {
    return isRequired((type as IntrospectionListTypeRef).ofType!);
  }

  return type.kind === TypeKind.NON_NULL;
};

export default isRequired;