klaaspieter / FakeQL

Automatic GraphQL mocks
MIT License
1 stars 0 forks source link

Resolvers don't work #2

Open MartinRougeron2 opened 4 years ago

MartinRougeron2 commented 4 years ago

Hi,

I'm using FakeQL to test some vue components, to have nice values, I use some resolvers to simulate true values. Also, the project is big and graphQL has 2 schemas, I setup graphQL tools to use the right schema. From this time, the resolvers don't work.

import { fakeQL } from "fakeql";
import { parse, buildSchema } from "graphql";
import { GET_ORDERS } from "src/constants/graphql";

const document = parse(GET_ORDERS.loc.source.body);

function getRandomArbitrary(min, max) {
  return Math.random() * (max - min) + min;
}

const mock = fakeQL({ document, resolvers: {
  Int() {
    return getRandomArbitrary(1, 50)
  },
  }});

And I get

 {
        id: 'mock-value-for-field-"id"',
        date: 'mock-value-for-field-"date"',
        updated: 'mock-value-for-field-"updated"',
        amountTotalTtc: 42,
        amountToBePaid: 42,
        ....
}

Don't hesitate to ask, if you want some details

klaaspieter commented 4 years ago

Hey @MartinRougeron2. Unfortunately I no longer use FakeQL in my own projects. I'm about to archive the repo as a matter of fact.

The code is pretty simple so I encourage you to take a look. Apologies for not marking this as unmaintained earlier 😞