Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dotansimha/graphql-code-generator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.17.2
Choose a base ref
...
head repository: dotansimha/graphql-code-generator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.17.3
Choose a head ref
  • 1 commit
  • 2 files changed
  • 2 contributors

Commits on Jul 21, 2020

  1. [urql] Respect omitOperationSuffix (#4405)

    Fixes #3968
    
    Co-authored-by: Daniel K <daniel@lovemyvoice.app>
    FredyC and Daniel K authored Jul 21, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d52543d View commit details
Showing with 29 additions and 1 deletion.
  1. +1 −1 packages/plugins/typescript/urql/src/visitor.ts
  2. +28 −0 packages/plugins/typescript/urql/tests/urql.spec.ts
2 changes: 1 addition & 1 deletion packages/plugins/typescript/urql/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ export const ${componentName} = (props: Omit<Urql.${operationType}Props<${generi
operationVariablesTypes: string
): string {
const operationName: string = this.convertName(node.name.value, {
suffix: pascalCase(operationType),
suffix: this.config.omitOperationSuffix ? '' : pascalCase(operationType),
useTypesPrefix: false,
});

28 changes: 28 additions & 0 deletions packages/plugins/typescript/urql/tests/urql.spec.ts
Original file line number Diff line number Diff line change
@@ -466,6 +466,20 @@ query MyFeed {
expect(content.content).not.toContain(`export class ITestComponent`);
});

it('should respect omitOperationSuffix for Component', async () => {
const docs = [{ location: '', document: basicDoc }];
const content = (await plugin(
schema,
docs,
{ omitOperationSuffix: true },
{
outputFile: 'graphql.tsx',
}
)) as Types.ComplexPluginOutput;

expect(content.content).not.toContain(`export class TestComponent`);
});

it('should add three generics if operation type is subscription', async () => {
const documents = parse(/* GraphQL */ `
subscription ListenToComments($name: String) {
@@ -601,5 +615,19 @@ export function useSubmitRepositoryMutation() {

expect(content.content).toContain(`export function useTestQuery`);
});

it('Should respect omitOperationSuffix for hooks', async () => {
const docs = [{ location: '', document: basicDoc }];
const content = (await plugin(
schema,
docs,
{ withHooks: true, omitOperationSuffix: true },
{
outputFile: 'graphql.tsx',
}
)) as Types.ComplexPluginOutput;

expect(content.content).toContain(`export function useTest(`);
});
});
});