-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from zeeshanakram3/add-graphql-query-to-get-pa…
…ckage-version Fix: Add graphql query to get package version
- Loading branch information
Showing
9 changed files
with
150 additions
and
35 deletions.
There are no files selected for viewing
6 changes: 2 additions & 4 deletions
6
db/migrations/1705345480233-Data.js → db/migrations/1705406586630-Data.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|
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 @@ | ||
export { SquidVersionResolver } from './squidVersion' |
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,37 @@ | ||
import fs from 'fs' | ||
import _ from 'lodash' | ||
import pkgDir from 'pkg-dir' | ||
import 'reflect-metadata' | ||
import { Field, ObjectType, Query, Resolver } from 'type-graphql' | ||
|
||
const pkgVersion = (): Promise<string> => { | ||
// Path to package.json file | ||
const packageJsonPath = `${pkgDir.sync()}/package.json` | ||
|
||
// Read the package.json file synchronously | ||
const data = fs.readFileSync(packageJsonPath, 'utf8') | ||
|
||
// Parse the JSON data | ||
const packageJson = JSON.parse(data) | ||
|
||
return packageJson.version | ||
} | ||
|
||
const memoizedPkgVersion = _.memoize(pkgVersion) | ||
|
||
@ObjectType() | ||
export class SquidVersion { | ||
@Field(() => String, { nullable: false }) | ||
version!: string | ||
} | ||
|
||
@Resolver() | ||
export class SquidVersionResolver { | ||
@Query(() => SquidVersion) | ||
async squidVersion(): Promise<SquidVersion> { | ||
// Get package version | ||
const version = await memoizedPkgVersion() | ||
|
||
return { version } | ||
} | ||
} |