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

Refactor odata handler #2473

Closed
wants to merge 6 commits into from
Closed

Conversation

habbes
Copy link
Contributor

@habbes habbes commented Jul 15, 2021

🚨 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

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

This PR does not introduce any changes in functionality or bug fixes. It does a bit of refactoring in the OData handler to make the code easier to navigate and make changes to. The motivation for this PR is that there are a couple of bug fixes and changes that I would like to contribute but have heard a hard time navigating the code since it's all in one large file.

I've split the code into separate files, the main ones being:

  • index.ts: still contains the ODataHandler class, but imports a lot of functionality from the other modules
  • request-processing.ts: helper functions for processing requests/responses from the OData service
  • schema-builder.ts: contains a GraphQLSchemaBuilder class that encasulates the GraphQL schema generation logic. The original code has also been split into separate methods that each handle generation of a specific schema element.

There's still room for improvement, but I think this is sufficient to work with, and further improvements can be made gradually when necessary when adding features/fixes.

Fixes #2466

Type of change

  • Code refactoring

Please delete options that are not relevant.

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • yarn test odata

Test Environment:

  • OS: Windows 10
  • @graphql-mesh/odata: 0.11.8
  • NodeJS: 14.0.0

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 and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

There's a snapshot test case in examples/odata-trippin that fails on my machine. This test was failing before I made changes to the repo. I am not sure why it fails, when I console.log the object being tested and manually compare it to the snapshot it's being compared to, it seems to match. I'm running the test using the following command: yarn test odata

image

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...

@changeset-bot
Copy link

changeset-bot bot commented Jul 15, 2021

⚠️ No Changeset found

Latest commit: 233e375

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@habbes habbes marked this pull request as ready for review July 15, 2021 16:37
@ardatan ardatan force-pushed the master branch 2 times, most recently from d518ad2 to 4f2928f Compare July 28, 2021 12:56
@ardatan
Copy link
Owner

ardatan commented Aug 4, 2021

@habbes Could you rebase the conflicts then I can merge this :)

@ardatan
Copy link
Owner

ardatan commented Aug 21, 2024

Sorry for the late response!
We just did a huge refactor in OData handler which inspired from your PR!
Thanks for the PR and all the work you did here!

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.

Refactor OData handler
2 participants