Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [graphql-request] pass variables to wrapper function #512

Merged

Conversation

axe-me
Copy link
Contributor

@axe-me axe-me commented Nov 24, 2023

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.

Description

Pass operation variables to wrapper function, so the wrapper function can use the variables to do conditional logic.

Related # (issue) #511

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

Adding links to sandbox or providing screenshots can help us understand more about this PR and take
action on it as appropriate

How Has This Been Tested?

Updated the unit tests

Test Environment:

  • OS:
  • @graphql-codegen/...:
  • NodeJS:

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose
the solution you did and what alternatives you considered, etc...

Copy link

changeset-bot bot commented Nov 24, 2023

🦋 Changeset detected

Latest commit: f4e830f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/typescript-graphql-request Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@axe-me
Copy link
Contributor Author

axe-me commented Nov 24, 2023

btw there is a failed test in master, I don't think it's my responsibility to fix it, so I leave it as is.

 FAIL  packages/presets/near-operation-file/tests/near-operation-file.spec.ts
  ● near-operation-file preset › Issues › #6439 - generating code only for the last query inside a file

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `near-operation-file preset Issues #6439 - generating code only for the last query inside a file 1`

    - Snapshot  - 1
    + Received  + 1

    @@ -1,6 +1,6 @@
    - import * as Types from '../../../../../out1.ts/types';
    + import * as Types from '../../../../plugins/typescript/graphql-request/out1.ts/types';

@axe-me
Copy link
Contributor Author

axe-me commented Dec 4, 2023

@dotansimha @saihaj Can you please review this MR?

@axe-me
Copy link
Contributor Author

axe-me commented Dec 12, 2023

just want to follow this up, @saihaj please review when you got a minute

@axe-me
Copy link
Contributor Author

axe-me commented Dec 15, 2023

ping @saihaj @dotansimha

@saihaj saihaj merged commit 34cdb37 into dotansimha:main Dec 18, 2023
7 checks passed
@saihaj
Copy link
Collaborator

saihaj commented Dec 18, 2023

released @graphql-codegen/[email protected]



const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType) => action();
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript is yelling because of that line:

error TS6133: 'variables' is declared but its value is never read.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing the same here after pulling in latest of graphql-request

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, this was also reported here and fixed here but the issue & PR have not gotten any response. It's a very trivial fix and your attention would be appreciated @saihaj or @axe-me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants