question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to specify local mock file

See original GitHub issue

First off, this project is amazing. It’s extremely useful for bootstrapping an app before the graphql server exists.

The faker methods are extremely useful, but I’m finding myself wishing I could run custom code to generate what I need in certain scenarios.

What if there was something like this

schema.faker.graphql

type JiraIssue {
  id: ID @fake(type: uuid)
  key: String @fake(type: mock, func: "jiraIssue")
}

graphql-faker-mocks.js

// Imagine this function does something more exciting
export const jiraIssue = () => 'ABC-123'

The semantics here might not be great. It could be a separate directive or the parameters could be different. Ultimately the idea is just to be able to custom mocks.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kunceviccommented, Oct 23, 2018

Yeah I see the use case where you need a constant predicted result, this might be useful for writing unit tests. Any progress on that @zephraph ?

0reactions
dguaycommented, Sep 16, 2021

Any news on this? It would be really interesting to be able to call a custom function to generate mock data for @fake and @examples directives.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to mock File in javascript? - Stack Overflow
The project consists of an audio player which has the ability to drag'n'drop files in a playlist. I'm using Jasmine as a testing...
Read more >
Using Mock to test package builds - Fedora Project Wiki
First, install the mock package, which is available from Fedora Package ... If you want to set up a local mirror, refer Docs/Drafts/ ......
Read more >
How to Quickly Mock an API Server in a Client-Side Project
I'm imagining a web application that allows users to upload files, then it shows a list of all the files that have been...
Read more >
Setting up a Local Mock API for your Front-end (React) Project
The solution was to start shipping all my frontend projects with a local mock API that matched the interface of the real backend...
Read more >
Setting up mock servers | Postman Learning Center
In the sidebar, select New and select Mock Server. ... Select an existing collection, or create a new collection and add an initial...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found