How to use the graphql-transformer-common.makeField 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-elasticsearch-transformer / src / SearchableModelTransformer.ts View on Github external
private generateSearchableXConnectionType(ctx: TransformerContext, def: ObjectTypeDefinitionNode): void {
    const searchableXConnectionName = `Searchable${def.name.value}Connection`;
    if (this.typeExist(searchableXConnectionName, ctx)) {
      return;
    }

    // Create the TableXConnection
    const connectionType = blankObject(searchableXConnectionName);
    ctx.addObject(connectionType);

    // Create TableXConnection type with items and nextToken
    let connectionTypeExtension = blankObjectExtension(searchableXConnectionName);
    connectionTypeExtension = extensionWithFields(connectionTypeExtension, [
      makeField('items', [], makeListType(makeNamedType(def.name.value))),
    ]);
    connectionTypeExtension = extensionWithFields(connectionTypeExtension, [
      makeField('nextToken', [], makeNamedType('String')),
      makeField('total', [], makeNamedType('Int')),
    ]);
    ctx.addObjectExtension(connectionTypeExtension);
  }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / DynamoDBModelTransformer.ts View on Github external
} else {
                deleteFieldNameOverride = directiveArguments.mutations.delete
            }
        }

        // 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(
github aws-amplify / amplify-cli / packages / graphql-elasticsearch-transformer / src / SearchableModelTransformer.ts View on Github external
const searchableXConnectionName = `Searchable${def.name.value}Connection`;
    if (this.typeExist(searchableXConnectionName, ctx)) {
      return;
    }

    // Create the TableXConnection
    const connectionType = blankObject(searchableXConnectionName);
    ctx.addObject(connectionType);

    // Create TableXConnection type with items and nextToken
    let connectionTypeExtension = blankObjectExtension(searchableXConnectionName);
    connectionTypeExtension = extensionWithFields(connectionTypeExtension, [
      makeField('items', [], makeListType(makeNamedType(def.name.value))),
    ]);
    connectionTypeExtension = extensionWithFields(connectionTypeExtension, [
      makeField('nextToken', [], makeNamedType('String')),
      makeField('total', [], makeNamedType('Int')),
    ]);
    ctx.addObjectExtension(connectionTypeExtension);
  }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / definitions.ts View on Github external
export function makeSubscriptionField(fieldName: string, returnTypeName: string, mutations: string[]): FieldDefinitionNode {
  return makeField(fieldName, [], makeNamedType(returnTypeName), [
    makeDirective('aws_subscribe', [makeArgument('mutations', makeValueNode(mutations))]),
  ]);
}
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / ModelAuthTransformer.ts View on Github external
private addOwner(ctx: TransformerContext, parent: string) {
        const modelType: any = ctx.getType(parent);
        const fields = getFieldArguments(modelType);
        if (!("owner" in fields)) {
            modelType.fields.push(
                makeField(
                    DEFAULT_OWNER_FIELD,
                    [],
                    makeNamedType('String'),
                )
            )
        }
        ctx.putType(modelType);
    }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / definitions.ts View on Github external
makeInputValueDefinition('filter', makeNamedType(ModelResourceIDs.ModelFilterInputTypeName(returnTypeName))),
    makeInputValueDefinition('sortDirection', makeNamedType('ModelSortDirection')),
    makeInputValueDefinition('limit', makeNamedType('Int')),
    makeInputValueDefinition('nextToken', makeNamedType('String')),
  ];
  if (sortKeyInfo) {
    let namedType: NamedTypeNode;
    if (sortKeyInfo.typeName === 'Composite') {
      namedType = makeNamedType(ModelResourceIDs.ModelCompositeKeyConditionInputTypeName(sortKeyInfo.model, toUpper(sortKeyInfo.keyName)));
    } else {
      namedType = makeNamedType(ModelResourceIDs.ModelKeyConditionInputTypeName(sortKeyInfo.typeName));
    }

    args.unshift(makeInputValueDefinition(sortKeyInfo.fieldName, namedType));
  }
  return makeField(fieldName, args, makeNamedType(ModelResourceIDs.ModelConnectionTypeName(returnTypeName)), directives);
}