How to use the graphql-transformer-common.makeNamedType function in graphql-transformer-common

To help you get started, we’ve selected a few graphql-transformer-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / definitions.ts View on Github external
if (functions.has('attributeExists')) {
    fields.push({
      kind: Kind.INPUT_VALUE_DEFINITION,
      name: { kind: 'Name' as 'Name', value: 'attributeExists' },
      type: makeNamedType('Boolean'),
      // TODO: Service does not support new style descriptions so wait.
      // description: field.description,
      directives: [],
    });
  }

  if (functions.has('attributeType')) {
    fields.push({
      kind: Kind.INPUT_VALUE_DEFINITION,
      name: { kind: 'Name' as 'Name', value: 'attributeType' },
      type: makeNamedType(ModelResourceIDs.ModelAttributeTypesName()),
      // TODO: Service does not support new style descriptions so wait.
      // description: field.description,
      directives: [],
    });
  }

  if (functions.has('size')) {
    fields.push({
      kind: Kind.INPUT_VALUE_DEFINITION,
      name: { kind: 'Name' as 'Name', value: 'size' },
      type: makeNamedType(ModelResourceIDs.ModelSizeInputTypeName()),
      // TODO: Service does not support new style descriptions so wait.
      // description: field.description,
      directives: [],
    });
  }
github aws-amplify / amplify-cli / packages / graphql-relation-transformer / src / ModelRelationTransformer.ts View on Github external
for (const filter of scalarFilters) {
            if (!this.typeExist(filter.name.value, ctx)) {
                ctx.addInput(filter)
            }
        }

        // Create the ModelXFilterInput
        const tableXQueryFilterInput = makeModelXFilterInputObject(field, ctx)
        if (!this.typeExist(tableXQueryFilterInput.name.value, ctx)) {
            ctx.addInput(tableXQueryFilterInput)
        }

        // Create sort key condition inputs for valid sort key types
        // We only create the KeyConditionInput if it is being used.
        if (sortKeyInfo) {
            const sortKeyConditionInput = makeScalarKeyConditionForType(makeNamedType(sortKeyInfo.typeName))
            if (!this.typeExist(sortKeyConditionInput.name.value, ctx)) {
                ctx.addInput(sortKeyConditionInput);
            }
        }
    }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / DynamoDBModelTransformer.ts View on Github external
}

        // Create the mutations.
        if (shouldMakeCreate) {
            const createInput = makeCreateInputObject(def, nonModelArray, ctx)
            if (!ctx.getType(createInput.name.value)) {
                ctx.addInput(createInput)
            }
            const createResolver = this.resources.makeCreateResolver(def.name.value, createFieldNameOverride)
            const resourceId = ResolverResourceIDs.DynamoDBCreateResolverResourceID(typeName);
            ctx.setResource(resourceId, createResolver)
            ctx.mapResourceToStack(typeName, resourceId);
            mutationFields.push(makeField(
                createResolver.Properties.FieldName,
                [makeInputValueDefinition('input', makeNonNullType(makeNamedType(createInput.name.value)))],
                makeNamedType(def.name.value)
            ));
        }

        if (shouldMakeUpdate) {
            const updateInput = makeUpdateInputObject(def, nonModelArray, ctx)
            if (!ctx.getType(updateInput.name.value)) {
                ctx.addInput(updateInput)
            }
            const updateResolver = this.resources.makeUpdateResolver(def.name.value, updateFieldNameOverride)
            const resourceId = ResolverResourceIDs.DynamoDBUpdateResolverResourceID(typeName);
            ctx.setResource(resourceId, updateResolver);
            ctx.mapResourceToStack(typeName, resourceId);
            mutationFields.push(makeField(
                updateResolver.Properties.FieldName,
                [makeInputValueDefinition('input', makeNonNullType(makeNamedType(updateInput.name.value)))],
                makeNamedType(def.name.value)
github aws-amplify / amplify-cli / packages / graphql-key-transformer / src / KeyTransformer.ts View on Github external
function addSimpleSortKey(ctx: TransformerContext, definition: ObjectTypeDefinitionNode, args: KeyArguments, elems: InputValueDefinitionNode[]): InputValueDefinitionNode[] {
    let sortKeyName = args.fields[1];
    const sortField = definition.fields.find(field => field.name.value === sortKeyName);
    const baseType = getBaseType(sortField.type);
    const resolvedTypeIfEnum = ctx.getType(baseType) as EnumTypeDefinitionNode ? 'String' : undefined;
    const resolvedType = resolvedTypeIfEnum ? resolvedTypeIfEnum : baseType;
    const hashKey = makeInputValueDefinition(sortKeyName, makeNamedType(ModelResourceIDs.ModelKeyConditionInputTypeName(resolvedType)));
    return [hashKey, ...elems];
}
function addCompositeSortKey(definition: ObjectTypeDefinitionNode, args: KeyArguments, elems: InputValueDefinitionNode[]): InputValueDefinitionNode[] {