Open basvandriel opened 2 years ago
Thanks for opening this issue! It would be helpful to add more information on this, so that we could understand the problem at hand and help out accordingly! 😄
I mean when defining a schema, allow a option for mocking data. For example, there is a query returning a array of numbers, without defining a resolver, the array will be randomized.
const { ApolloServer, gql } = require('apollo-server');
const typeDefs = gql`
type Query {
hello: String
resolved: String
}
`;
const resolvers = {
Query: {
resolved: () => 'Resolved',
},
};
const mocks = {
Int: () => 6,
Float: () => 22.1,
String: () => 'Hello',
};
const server = new ApolloServer({
typeDefs,
resolvers,
mocks,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`)
});
I think this could be best implemented as a plugin, and @jkimbo already suggested this!
For context here is a proof of concept of how mocking could work: https://replit.com/@jkimbo/BiodegradableInfiniteModem#main.py
And here is the discord thread where we discussed it: https://discord.com/channels/689806334337482765/890981673041289227/890991139858038825
from here
Upvote & Fund