Product
Introducing Socket Optimize
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.
graphql-rest-mocks
Advanced tools
Run npm i graphql-rest-mocks
Create a folder called ./contracts
in your repository
Add a file called HelloWorld.graphql
, with these contents:
type Request {
id: ID!
}
type Response {
string: String!
}
Add this script to your package.json:
{
"scripts": {
"start": "graphql-rest-mocks start ./contracts"
}
}
Run npm run start
Visit localhost:4000/HelloWorld?id=200
You'll see a mock server producing data.
Create a folder called ./types
Add a file called GlobalType.graphql
, with these contents:
type GlobalType {
someGlobalId: ID!
}
Change HelloWorld.graphql
to use that global type, as below:
type Request {
id: ID!
}
type Response {
string: String!
globalType: GlobalType!
}
No need to import it, or do anything fancy. Any type, scalar or enum declared in the global types folder is available to all contracts.
Change the script to use the types folder:
{
"scripts": {
"start": "graphql-rest-mocks start ./contracts --types ./types"
}
}
https://www.apollographql.com/docs/apollo-server/schemas/types.html
TL;DR:
Int
Float
String
ID
Boolean
FAQs
Mock a REST API using GraphQL
The npm package graphql-rest-mocks receives a total of 1 weekly downloads. As such, graphql-rest-mocks popularity was classified as not popular.
We found that graphql-rest-mocks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.