-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(float-field): should work with codegen (#151)
- Loading branch information
1 parent
223c13b
commit f5c16bd
Showing
27 changed files
with
265 additions
and
60 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
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
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,70 @@ | ||
import * as Faker from 'faker'; | ||
|
||
import { getBindingError, logger } from '../../../src'; | ||
|
||
import { getServer } from '../src/server'; | ||
|
||
if (process.env.NODE_ENV !== 'development') { | ||
throw 'Seeding only available in development environment'; | ||
} | ||
|
||
const NUM_USERS = 10; | ||
|
||
async function seedDatabase() { | ||
const server = getServer({ openPlayground: false }); | ||
await server.start(); | ||
|
||
let binding; | ||
try { | ||
binding = await server.getBinding(); | ||
} catch (error) { | ||
logger.error(error); | ||
return process.exit(1); | ||
} | ||
|
||
for (let index = 0; index < NUM_USERS; index++) { | ||
const random = new Date() | ||
.getTime() | ||
.toString() | ||
.substring(8, 13); | ||
const firstName = Faker.name.firstName(); | ||
const lastName = Faker.name.lastName(); | ||
const email = `${firstName | ||
.substr(0, 1) | ||
.toLowerCase()}${lastName.toLowerCase()}-${random}@fakeemail.com`; | ||
|
||
try { | ||
const user = await binding.mutation.createUser( | ||
{ | ||
data: { | ||
age: Faker.random.number({ min: 10, max: 100 }), | ||
email, | ||
firstName, | ||
isRequired: Faker.random.arrayElement([true, false]), | ||
lastName, | ||
rating: Faker.random.number({ min: 1, max: 5 }), | ||
stringEnumField: Faker.random.arrayElement(['FOO', 'BAR']) | ||
} | ||
}, | ||
`{ id email createdAt createdById }` | ||
); | ||
logger.info(user.email); | ||
} catch (err) { | ||
const error = getBindingError(err); | ||
logger.error(email); | ||
logger.error(error); | ||
} | ||
} | ||
|
||
return server.stop(); | ||
} | ||
|
||
seedDatabase() | ||
.then(result => { | ||
logger.info(result); | ||
return process.exit(0); | ||
}) | ||
.catch(err => { | ||
logger.error(err); | ||
return process.exit(1); | ||
}); |
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
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.