I am trying to generate a list of 10 items in my GraphQL mock server like this:
import { makeExecutableSchema, addMockFunctionsToSchema, MockList } from 'graphql-tools';
import casual from 'casual';
import typeDefs from './schema.graphql';
export const schema = makeExecutableSchema({ typeDefs });
const mocks = {
File: () => ({
path: casual.random_element([
'/assets/images/cars/1.JPG',
'/assets/images/cars/2.JPG',
'/assets/images/cars/3.JPG',
'/assets/images/cars/4.JPG',
'/assets/images/cars/5.JPG',
'/assets/images/cars/6.JPG',
'/assets/images/cars/7.JPG',
]),
}),
UsedCar: () =>
new MockList(10, () => ({
price: casual.integer(10000, 99999999),
year: casual.integer(1990, 2017),
})),
};
// This function call adds the mocks to your schema!
addMockFunctionsToSchema({ schema, mocks });
But I always get two used cars I don't know why. Can anyone help?
Regards, Mostafa