GithubHelp home page GithubHelp logo

Comments (2)

vektah avatar vektah commented on May 21, 2024

Interesting idea. How would this work? The schema might tell you enough for basic types, some of the time, eg 'string' = 'asdf', but what about custom scalars? use the zero value? but I feel like getting tests to pass any user implemented validation (eg user id must be a valid id) would be really tricky. It probably ends up looking like the apollo mocking api but backwards.

I usually write tests to cover the graph manually, executing mutations and asserting that they are present in the query. There is a client package in this repo to make that a little easier. Take a look at the tests in any of the examples eg

from gqlgen.

jacklaaa89 avatar jacklaaa89 commented on May 21, 2024

I think that the tests for the generated code should only test that the code generated is valid and does what is expected. In this scenario we could mock the Resolvers interface generated as this is the root node to the query (the query and mutation fields) and we can control from the top level the objects which are returned and resolved further down the tree, assuming that we can initialise user generated mocks, using the structures themselves or a package like mock

I think that these tests should not have to worry about user implemented validation, as stated above we can control the objects returned from root nodes, and any resolver funcs lower down the tree.

As you stated, the difficulty is in Custom scalar types.

from gqlgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.