Closed
Description
Is it possible to validate a JSON document against a GraphQL Output Type?
I found these docs: https://graphql.org/graphql-js/utilities/
I am able to load the schema and get the types. I can't work out how to validate a JSON doc against one of those types though.
I've tried astFromValue
and isValidJSValue
; both without success.
Please help :)
This is where I am thus far:
jest.disableAutomock();
const fs = require("fs");
const graphql = require("graphql");
const yaml = require("js-yaml");
test("adds 1 + 2 to equal 3", () => {
const teamMemberSchema = fs.readFileSync(
"../../schemas/graphql/team/member.graphql",
"utf8"
);
const schema = graphql.buildSchema(teamMemberSchema);
const members = yaml.safeLoadAll(
fs.readFileSync("../../examples/team/member.yaml", "utf8")
);
members.map(member => {
const result = ???;
console.log(result);
});
expect(1 + 2).toBe(3);
});