graphql#IntrospectionListTypeRef TypeScript Examples

The following examples show how to use graphql#IntrospectionListTypeRef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: buildData.ts    From ra-data-prisma with MIT License 6 votes vote down vote up
getCreateInputDataTypeForList = (
  createModifier: IntrospectionInputValue,
  introspectionResults: IntrospectionResult,
) => {
  const createListModifierType =
    createModifier.type as IntrospectionListTypeRef<
      IntrospectionNonNullTypeRef<any>
    >;
  const createInputFieldType =
    createListModifierType.ofType.kind === "NON_NULL"
      ? createListModifierType.ofType.ofType
      : createListModifierType.ofType;
  return introspectionResults.types.find(
    // what about a nullable type?
    (t) => t.name === createInputFieldType.name,
  ) as IntrospectionInputObjectType;
}
Example #2
Source File: buildData.ts    From ra-data-prisma with MIT License 6 votes vote down vote up
getUpdateInputDataTypeForList = (
  updateModifier: IntrospectionInputValue,
  introspectionResults: IntrospectionResult,
) => {
  const updateListModifierType =
    updateModifier.type as IntrospectionListTypeRef<
      IntrospectionNonNullTypeRef<any>
    >;
  const updateInputFieldType = getFinalType(updateListModifierType.ofType);
  const updateListInputDataType = (
    introspectionResults.types.find(
      (introdspectionType) =>
        introdspectionType.name === updateInputFieldType.name,
    ) as IntrospectionInputObjectType
  ).inputFields.find((input) => input.name === "data")
    .type as IntrospectionTypeRef;

  const updateListInputDataName = (
    (updateListInputDataType.kind === "NON_NULL"
      ? updateListInputDataType.ofType
      : updateListInputDataType) as IntrospectionNamedTypeRef
  ).name;

  return introspectionResults.types.find(
    (introdspectionType) => introdspectionType.name === updateListInputDataName,
  ) as IntrospectionInputObjectType;
}
Example #3
Source File: getFinalType.ts    From ra-data-prisma with MIT License 6 votes vote down vote up
getFinalType = (
  type: IntrospectionTypeRef,
): IntrospectionNamedTypeRef => {
  if (type.kind === TypeKind.NON_NULL || type.kind === TypeKind.LIST) {
    return getFinalType(
      (type as IntrospectionListTypeRef | IntrospectionNonNullTypeRef).ofType!,
    );
  }

  return type as IntrospectionNamedTypeRef;
}
Example #4
Source File: isRequired.ts    From ra-data-prisma with MIT License 5 votes vote down vote up
isRequired = (type: IntrospectionTypeRef): boolean => {
  if (type.kind === TypeKind.LIST) {
    return isRequired((type as IntrospectionListTypeRef).ofType!);
  }

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