Skip to content

Commit

Permalink
fixed typings
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Jan 12, 2024
1 parent 5f5a964 commit 8555eb1
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ Mock server should be running on port 4000

## Configuration
Demeter will automatically create config file on the first start `.graphql.demeter.js`.

![](./readme.png)

As you can see if you provide type it will autocomplete faker values

```js
Expand All @@ -40,16 +37,13 @@ const config = {
objects: {
Card:{
description:{
type:"values",
values:["Very powerful card", "Most fire resistant character", "Good melee fighter"]
},
name:{
type:"values",
values:["Zeus", "Athena", "Hera", "Ares", "Kronos"]
},
image:{
type:"faker",
key:"internet.avatar"
fake:"internet.avatar"
}
}
},
Expand Down
10 changes: 9 additions & 1 deletion examples/olympus/.graphql.demeter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ const config = {
values:["Zeus", "Athena", "Hera", "Ares", "Kronos"]
},
image:{
key: "image.people"
fake: "image.people"
}
},
S3Object:{
bucket:{
fake: "address.country"
},
region:{
fake: "address.country"
},
}
},
scalars: {},
Expand Down
6 changes: 3 additions & 3 deletions examples/olympus/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "olympus",
"version": "1.1.4",
"version": "1.1.5",
"description": "Example of using GraphQL Demeter",
"private": true,
"main": "index.js",
"scripts": {
"start": "node ../../node_modules/.bin/demeter zeus.graphql"
"start": "nodemon --watch .graphql.demeter.js ../../node_modules/graphql-demeter/lib/index.js zeus.graphql"
},
"author": "Aexol <[email protected]> (http://aexol.com)",
"license": "ISC",
"dependencies": {
"graphql-demeter": "^1.0.1"
"graphql-demeter": "^1.0.2"
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"clean-packages": "rimraf packages/**/lib && rimraf packages/**/tsconfig.tsbuildinfo",
"build": "npm run clean-packages && npm run build --ws --if-present",
"lint": "tspc && eslint \"./packages/**/src/**/*.{ts,js}\" --quiet --fix",
"cli": "node ./packages/graphql-demeter/lib/index.js",
"dev": "npm run build && concurrently \"npm run start -w graphql-demeter-core\" \"npm run start -w graphql-demeter\" \"npm run start -w olympus\" ",
"example": "npm run start -w olympus",
"run-example": "npm run build && npm run example",
"test": "jest"
Expand All @@ -28,11 +28,13 @@
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"husky": "^8.0.3",
"jest": "^29.7.0",
"nodemon": "^3.0.2",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-demeter-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-demeter-core",
"version": "1.0.1",
"version": "1.0.2",
"private": false,
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-demeter-core/src/MockServer/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type FakerConfiguratedField =
values: Array<string | number>;
}
| {
key: AllowedFakerStrings;
fake: AllowedFakerStrings;
};

export type FakerConfig = {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-demeter-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const createFakeResolvers = (schemaString: string, fakerConfig?: FakerCon
if ([ScalarTypes.ID, ScalarTypes.String].includes(tName as ScalarTypes)) {
return mockValue(a.type.fieldType, () => {
const valueFromFaker =
resolverValues && 'key' in resolverValues ? fakeValue(resolverValues.key) : fakeValue(a.name);
resolverValues && 'fake' in resolverValues ? fakeValue(resolverValues.fake) : fakeValue(a.name);
if (typeof valueFromFaker !== 'string') {
return fakeScalar(tName)();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-demeter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-demeter",
"version": "1.0.1",
"version": "1.0.2",
"private": false,
"scripts": {
"start": "tspc --watch",
Expand All @@ -26,7 +26,7 @@
"dependencies": {
"cross-fetch": "^3.0.4",
"graphql": "15.4.0",
"graphql-demeter-core": "^1.0.1",
"graphql-demeter-core": "^1.0.2",
"graphql-yoga": "^5.1.1",
"yargs": "^16.1.1"
},
Expand Down

0 comments on commit 8555eb1

Please sign in to comment.