Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

apollo-codegen

Package Overview
Dependencies
104
Maintainers
3
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.18.4 to 0.18.5

10

lib/swift/codeGeneration.js

@@ -329,5 +329,5 @@ "use strict";

propertyAssignmentForField(field) {
const { responseKey, propertyName, type, structName } = field;
const { responseKey, propertyName, type, isConditional, structName } = field;
const valueExpression = graphql_1.isCompositeType(graphql_1.getNamedType(type))
? this.helpers.mapExpressionForType(type, expression => `${expression}.snapshot`, language_1.escapeIdentifierIfNeeded(propertyName), structName)
? this.helpers.mapExpressionForType(type, isConditional, expression => `${expression}.snapshot`, language_1.escapeIdentifierIfNeeded(propertyName), structName)
: language_1.escapeIdentifierIfNeeded(propertyName);

@@ -337,3 +337,3 @@ return `"${responseKey}": ${valueExpression}`;

propertyDeclarationForField(field) {
const { responseKey, propertyName, typeName, type, isOptional } = field;
const { responseKey, propertyName, typeName, type, isOptional, isConditional } = field;
const unmodifiedFieldType = graphql_1.getNamedType(type);

@@ -358,7 +358,7 @@ this.printNewlineIfNeeded();

}
this.printOnNewline(`return ${this.helpers.mapExpressionForType(type, expression => `${structName}(snapshot: ${expression})`, expression, 'Snapshot')}`);
this.printOnNewline(`return ${this.helpers.mapExpressionForType(type, isConditional, expression => `${structName}(snapshot: ${expression})`, expression, 'Snapshot')}`);
});
this.printOnNewline('set');
this.withinBlock(() => {
let newValueExpression = this.helpers.mapExpressionForType(type, expression => `${expression}.snapshot`, 'newValue', structName);
let newValueExpression = this.helpers.mapExpressionForType(type, isConditional, expression => `${expression}.snapshot`, 'newValue', structName);
this.printOnNewline(`snapshot.updateValue(${newValueExpression}, forKey: "${responseKey}")`);

@@ -365,0 +365,0 @@ });

@@ -158,6 +158,6 @@ "use strict";

}
mapExpressionForType(type, makeExpression, expression, structName) {
mapExpressionForType(type, isConditional = false, makeExpression, expression, structName) {
let isOptional;
if (type instanceof graphql_1.GraphQLNonNull) {
isOptional = false;
isOptional = !!isConditional;
type = type.ofType;

@@ -170,6 +170,6 @@ }

if (isOptional) {
return `${expression}.flatMap { ${makeClosureSignature(this.typeNameFromGraphQLType(type, structName, false))} value.map { ${this.mapExpressionForType(type.ofType, makeExpression, `${makeClosureSignature(this.typeNameFromGraphQLType(type.ofType, structName))} value`, structName)} } }`;
return `${expression}.flatMap { ${makeClosureSignature(this.typeNameFromGraphQLType(type, structName, false))} value.map { ${this.mapExpressionForType(type.ofType, undefined, makeExpression, `${makeClosureSignature(this.typeNameFromGraphQLType(type.ofType, structName))} value`, structName)} } }`;
}
else {
return `${expression}.map { ${makeClosureSignature(this.typeNameFromGraphQLType(type, structName))} ${this.mapExpressionForType(type, makeExpression, 'value', structName)} }`;
return `${expression}.map { ${makeClosureSignature(this.typeNameFromGraphQLType(type.ofType, structName))} ${this.mapExpressionForType(type.ofType, undefined, makeExpression, 'value', structName)} }`;
}

@@ -176,0 +176,0 @@ }

{
"name": "apollo-codegen",
"version": "0.18.4",
"version": "0.18.5",
"description": "Generate API code or type annotations based on a GraphQL schema and query documents",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -493,7 +493,8 @@ import * as path from 'path';

propertyAssignmentForField(field: { responseKey: string; propertyName: string; type: GraphQLType, structName?: string }) {
const { responseKey, propertyName, type, structName } = field;
propertyAssignmentForField(field: { responseKey: string; propertyName: string; type: GraphQLType, isConditional?: boolean, structName?: string }) {
const { responseKey, propertyName, type, isConditional, structName } = field;
const valueExpression = isCompositeType(getNamedType(type))
? this.helpers.mapExpressionForType(
type,
isConditional,
expression => `${expression}.snapshot`,

@@ -508,3 +509,3 @@ escapeIdentifierIfNeeded(propertyName),

propertyDeclarationForField(field: Field & Property) {
const { responseKey, propertyName, typeName, type, isOptional } = field;
const { responseKey, propertyName, typeName, type, isOptional, isConditional } = field;

@@ -535,2 +536,3 @@ const unmodifiedFieldType = getNamedType(type);

type,
isConditional,
expression => `${structName}(snapshot: ${expression})`,

@@ -545,2 +547,3 @@ expression,

type,
isConditional,
expression => `${expression}.snapshot`,

@@ -547,0 +550,0 @@ 'newValue',

@@ -233,2 +233,3 @@ import {

type: GraphQLType,
isConditional: boolean = false,
makeExpression: (expression: string) => string,

@@ -240,3 +241,3 @@ expression: string,

if (type instanceof GraphQLNonNull) {
isOptional = false;
isOptional = !!isConditional;
type = type.ofType;

@@ -253,2 +254,3 @@ } else {

type.ofType,
undefined,
makeExpression,

@@ -260,4 +262,4 @@ `${makeClosureSignature(this.typeNameFromGraphQLType(type.ofType, structName))} value`,

return `${expression}.map { ${makeClosureSignature(
this.typeNameFromGraphQLType(type, structName)
)} ${this.mapExpressionForType(type, makeExpression, 'value', structName)} }`;
this.typeNameFromGraphQLType(type.ofType, structName)
)} ${this.mapExpressionForType(type.ofType, undefined, makeExpression, 'value', structName)} }`;
}

@@ -278,40 +280,1 @@ } else if (isOptional) {

/*
mapExpressionForType2(
type: GraphQLType,
expression: (identifier: string) => string,
identifier: string = '',
subtypeName: string
): string {
let isOptional;
if (type instanceof GraphQLNonNull) {
isOptional = false;
type = type.ofType;
} else {
isOptional = true;
}
if (type instanceof GraphQLList) {
if (isOptional) {
const prologue = subtypeName === undefined ? '' : `(i: ${subtypeName}) in `
const subidentifier = subtypeName === undefined ? '$0' : 'i'
return `${identifier}?.map({ ${prologue}${this.mapExpressionForType(
type.ofType,
expression,
subidentifier,
this.typeNameFromGraphQLType(type.ofType, undefined, false, true)
)} })`;
} else {
const prologue = subtypeName === undefined ? '' : `(j: ${subtypeName}) in `
const subidentifier = subtypeName === undefined ? '$0' : 'j'
return `${identifier}.map { ${prologue}${this.mapExpressionForType(type.ofType, expression, subidentifier, this.typeNameFromGraphQLType(type, undefined, false, true))} }`;
}
} else if (isOptional) {
const prologue = subtypeName === undefined ? '' : `(j: ${subtypeName}) in `
const subidentifier = subtypeName === undefined ? '$0' : 'j'
return `${identifier}.flatMap { ${prologue}${expression(subidentifier)} }`;
} else {
return expression(identifier);
}
}
}
*/

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc