-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apps/gql): add RafineQuery with metadata query & resolver (#699)
# Description introducing Rafine as a MVP. Kinda still WIP. Please describe your changes. Be descriptive enough to reduce churn for review process. ### Checklist - [x] discord username: `csirin` - [x] Closes #643 - [x] Closes #644 - [x] Closes #645 - [ ] PR must be created for an issue from issues under "In progress" column from [our project board](https://github.com/orgs/kamp-us/projects/2/views/1). - [x] A descriptive and understandable title: The PR title should clearly describe the nature and purpose of the changes. The PR title should be the first thing displayed when the PR is opened. And it should follow the semantic commit rules, and should include the app/package/service name in the title. For example, a title like "docs(@kampus-apps/pano): Add README.md" can be used. - [x] Related file selection: Only relevant files should be touched and no other files should be affected. - [ ] I ran `npx turbo run` at the root of the repository, and build was successful. - [x] I installed the npm packages using `npm install --save-exact <package>` so my package is pinned to a specific npm version. Leave empty if no package was installed. Leave empty if no package was installed with this PR. ### How were these changes tested? Please describe the tests you did to test the changes you made. Please also specify your test configuration. --------- Co-authored-by: Can Sirin <[email protected]> Co-authored-by: Umut Sirin <[email protected]>
- Loading branch information
1 parent
69feccf
commit 80173d5
Showing
7 changed files
with
7,496 additions
and
6,277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { parser, type Metadata } from "html-metadata-parser"; | ||
|
||
import { createDataLoader } from "~/../../packages/gql-utils"; | ||
import { type RafineMetadata } from "~/schema/types.generated"; | ||
|
||
export const createRafineLoaders = () => { | ||
return { | ||
metadata: createMetadataLoader(), | ||
}; | ||
}; | ||
|
||
const createMetadataLoader = () => { | ||
const parse = createDataLoader<string, Metadata>( | ||
async (urls) => await Promise.all(urls.map((url) => parser(url))) | ||
); | ||
|
||
return { | ||
parse, | ||
}; | ||
}; | ||
|
||
export const transformMetadata = (metadata: Metadata) => { | ||
return { | ||
...metadata, | ||
description: metadata.meta.description || "", | ||
title: metadata.meta.title || "", | ||
url: metadata.meta.url || "", | ||
__typename: "RafineMetadata", | ||
} satisfies RafineMetadata; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.