Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs to add "graphql-tools" better examples #39

Open
wenderjean opened this issue Jul 15, 2020 · 2 comments
Open

Improve docs to add "graphql-tools" better examples #39

wenderjean opened this issue Jul 15, 2020 · 2 comments

Comments

@wenderjean
Copy link

wenderjean commented Jul 15, 2020

Hey guys,

Do you think it worths adding more examples on README regarding the integration with graphql-tools? It took some time to me to understand how to add my custom scalars on mockGraphql, even though it is pretty straightforward I had to took a look at the source to have a clear understanding on it. :)

@jfairley
Copy link

jfairley commented Dec 7, 2020

@wenderjean I'm trying to figure that out myself. Care to point me to how to define a custom scalar?

@jfairley
Copy link

jfairley commented Dec 7, 2020

I ended up making something like this: #17 (comment)

I created a Date scalar in my backend which is a without-time date (like "2020-12-07").

Added this to my test. Not exactly sure if it's the "right" thing, but it works for my case.

    cy.mockGraphql({
      ...
      mocks: {
        Date(obj, args, context, field) {
          if (obj[field.fieldName]) return obj[field.fieldName];
          if (field.variableValues[field.fieldName]) return field.variableValues[field.fieldName];
          return "2020-11-11";
        },
      },
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants