Skip to content

Commit

Permalink
upgrade to prettier v3
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Sep 5, 2024
1 parent a0f14ea commit 49a2999
Show file tree
Hide file tree
Showing 27 changed files with 207 additions and 314 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ dist/
CHANGELOG.md
.husky/_/
.changeset/*.md
# Ignore all flow files cause it is just hard to maintain them
*.flow.js
2 changes: 1 addition & 1 deletion dev-test/githunt/types.urql.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IntrospectionQuery } from 'graphql';
import gql from 'graphql-tag';
import * as Urql from 'urql';
import { cacheExchange } from '@urql/exchange-graphcache';
import {
cacheExchange,
OptimisticMutationResolver as GraphCacheOptimisticMutationResolver,
Resolver as GraphCacheResolver,
UpdateResolver as GraphCacheUpdateResolver,
Expand Down
26 changes: 19 additions & 7 deletions logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@babel/preset-typescript": "7.24.7",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.8",
"@theguild/prettier-config": "1.1.2",
"@theguild/prettier-config": "2.0.7",
"@types/jest": "28.1.8",
"@types/node": "20.16.5",
"@typescript-eslint/eslint-plugin": "7.18.0",
Expand All @@ -53,7 +53,7 @@
"jest-junit": "16.0.0",
"lint-staged": "15.2.10",
"patch-package": "8.0.0",
"prettier": "2.8.5",
"prettier": "3.3.3",
"rimraf": "6.0.1",
"ts-jest": "28.0.8",
"ts-node": "10.9.2",
Expand All @@ -65,7 +65,6 @@
"graphql": "16.9.0",
"graphql-language-service-interface": "2.10.2",
"jest-runner": "28.1.3",
"prettier": "2.8.5",
"ts-node": "10.9.2"
},
"lint-staged": {
Expand Down
12 changes: 6 additions & 6 deletions packages/plugins/c-sharp/c-sharp-operations/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ export class CSharpOperationsVisitor extends ClientSideBaseVisitor<
this.config.dedupeOperationSuffix && node.name.value.toLowerCase().endsWith(node.operation)
? ''
: !operationType
? ''
: operationType;
? ''
: operationType;

const operationResultType: string = this.convertName(node, {
suffix: operationTypeSuffix + this._parsedConfig.operationResultSuffix,
Expand Down Expand Up @@ -569,11 +569,11 @@ ${this._getOperationMethod(node)}
return new GraphQLRequest {
Query = ${this._getDocumentNodeVariable(node, documentVariableName)},
OperationName = "${node.name.value}"${
hasInputArgs
? `,
hasInputArgs
? `,
Variables = variables`
: ''
}
: ''
}
};
}
Expand Down
5 changes: 4 additions & 1 deletion packages/plugins/c-sharp/c-sharp/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export class CSharpResolversVisitor extends BaseVisitor<
> {
private readonly jsonAttributesConfiguration: JsonAttributesSourceConfiguration;

constructor(rawConfig: CSharpResolversPluginRawConfig, private _schema: GraphQLSchema) {
constructor(
rawConfig: CSharpResolversPluginRawConfig,
private _schema: GraphQLSchema,
) {
super(rawConfig, {
enumValues: rawConfig.enumValues || {},
listType: rawConfig.listType || 'List',
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/dart/flutter-freezed/src/config/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ export class Pattern {
return patternType === 'TypeNamePattern'
? baseNamesForTypeNamePattern
: patternType === 'FieldNamePattern'
? baseNamesForFieldNamePattern
: [...baseNamesForTypeNamePattern, ...baseNamesForFieldNamePattern];
? baseNamesForFieldNamePattern
: [...baseNamesForTypeNamePattern, ...baseNamesForFieldNamePattern];
};
//#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ ${allMarshallers.join('\n')}
isNonNull ? '' : '@Nullable '
}${fieldType}) {
this.${field.name.value} = ${
isNonNull ? field.name.value : `Input.fromNullable(${field.name.value})`
};
isNonNull ? field.name.value : `Input.fromNullable(${field.name.value})`
};
return this;
}`;
})
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/java/apollo-android/src/operation-visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,8 @@ ${childFields
@Override
public void write(Object value, ResponseWriter.ListItemWriter listItemWriter) {
listItemWriter.${writerMethod.name}(((${f.className}) value)${
writerMethod.useMarshaller ? '.marshaller()' : ''
});
writerMethod.useMarshaller ? '.marshaller()' : ''
});
}
});`,
2,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/apollo-angular/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ ${camelCase(o.node.name.value)}Watch(variables${
const providedIn = this.config.serviceProvidedIn
? `{ providedIn: ${this._parseNgModule(this.config.serviceProvidedIn).module} }`
: this.config.serviceProvidedInRoot === false
? ''
: `{ providedIn: 'root' }`;
? ''
: `{ providedIn: 'root' }`;

// Generate these types only if they're going to be used,
// to avoid "unused variable" compile errors in generated code
Expand Down
45 changes: 24 additions & 21 deletions packages/plugins/typescript/apollo-client-helpers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,42 @@ function generateTypePoliciesSignature(
): Types.ComplexPluginOutput {
const typeMap = schema.getTypeMap();
const perTypePolicies: string[] = [];
const typedTypePolicies = Object.keys(typeMap).reduce((prev, typeName) => {
const type = typeMap[typeName];
const typedTypePolicies = Object.keys(typeMap).reduce(
(prev, typeName) => {
const type = typeMap[typeName];

if (!typeName.startsWith('__') && (isObjectType(type) || isInterfaceType(type))) {
const fieldsNames = Object.keys(type.getFields()).filter(f => !f.startsWith('__'));
const keySpecifierVarName = `${typeName}KeySpecifier`;
const fieldPolicyVarName = `${typeName}FieldPolicy`;
if (!typeName.startsWith('__') && (isObjectType(type) || isInterfaceType(type))) {
const fieldsNames = Object.keys(type.getFields()).filter(f => !f.startsWith('__'));
const keySpecifierVarName = `${typeName}KeySpecifier`;
const fieldPolicyVarName = `${typeName}FieldPolicy`;

perTypePolicies.push(
`export type ${keySpecifierVarName} = (${fieldsNames
.map(f => `'${f}'`)
.join(' | ')} | ${keySpecifierVarName})[];`,
);
perTypePolicies.push(
`export type ${keySpecifierVarName} = (${fieldsNames
.map(f => `'${f}'`)
.join(' | ')} | ${keySpecifierVarName})[];`,
);

perTypePolicies.push(`export type ${fieldPolicyVarName} = {
perTypePolicies.push(`export type ${fieldPolicyVarName} = {
${fieldsNames
.map(fieldName => `\t${fieldName}?: FieldPolicy<any> | FieldReadFunction<any>`)
.join(',\n')}
};`);

return {
...prev,
[typeName]: `Omit<TypePolicy, "fields" | "keyFields"> & {
return {
...prev,
[typeName]: `Omit<TypePolicy, "fields" | "keyFields"> & {
\t\tkeyFields${
config.requireKeyFields ? '' : '?'
}: false | ${keySpecifierVarName} | (() => undefined | ${keySpecifierVarName}),
config.requireKeyFields ? '' : '?'
}: false | ${keySpecifierVarName} | (() => undefined | ${keySpecifierVarName}),
\t\tfields?: ${fieldPolicyVarName},
\t}`,
};
}
};
}

return prev;
}, {} as Record<string, string>);
return prev;
},
{} as Record<string, string>,
);

const rootTypes = [
schema.getQueryType()?.name,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/typescript/enum-array/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function buildArrayDefinition(e: GraphQLEnumType, config: EnumArrayPluginConfig)
const convert = convertFactory(config);

const enumName = convert(e.astNode, {
prefix: config.enumPrefix ?? true ? config.typesPrefix : undefined,
prefix: (config.enumPrefix ?? true) ? config.typesPrefix : undefined,
suffix: config.typesSuffix,
});

Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/generic-sdk/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export class GenericSdkVisitor extends ClientSideBaseVisitor<
o.operationVariablesTypes
}, options?: C): ${returnType}<${resultData}> {
return requester<${o.operationResultType}, ${
o.operationVariablesTypes
}>(${docVarName}, variables, options) as ${returnType}<${resultData}>;
o.operationVariablesTypes
}>(${docVarName}, variables, options) as ${returnType}<${resultData}>;
}`;
})
.map(s => indentMultiline(s, 2));
Expand Down
8 changes: 4 additions & 4 deletions packages/plugins/typescript/graphql-apollo/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ export class GraphQLApolloVisitor extends ClientSideBaseVisitor<
x.operationType
}(options: Partial<${optionType}<${genericParameter.join(', ')}>>) {
return client.${GraphQLApolloVisitor.getApolloOperation(x.operationType)}<${generics.join(
', ',
)}>({...options, ${GraphQLApolloVisitor.getDocumentFieldName(
x.operationType,
)}: ${documentVariableName}})
', ',
)}>({...options, ${GraphQLApolloVisitor.getDocumentFieldName(
x.operationType,
)}: ${documentVariableName}})
}`;
});
return `export const getSdk = (client: ApolloClient<any>) => ({
Expand Down
5 changes: 4 additions & 1 deletion packages/plugins/typescript/mongodb/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export class TsMongoVisitor extends BaseVisitor<
TypeScriptMongoPluginConfig,
TypeScriptMongoPluginParsedConfig
> {
constructor(private _schema: GraphQLSchema, pluginConfig: TypeScriptMongoPluginConfig) {
constructor(
private _schema: GraphQLSchema,
pluginConfig: TypeScriptMongoPluginConfig,
) {
super(pluginConfig, {
dbTypeSuffix: pluginConfig.dbTypeSuffix || 'DbObject',
dbInterfaceSuffix: pluginConfig.dbInterfaceSuffix || 'DbInterface',
Expand Down
Loading

0 comments on commit 49a2999

Please sign in to comment.