Hi guys,
I'm trying to use this beautiful library in the following code, but it throws an exception:
/Users/xxx/Works/gql/node_modules/graphql/utilities/astFromValue.js:132
throw _iteratorError;
^
TypeError: Cannot convert value to AST: { key: "value" }
at astFromValue (/Users/xxx/Works/gql/node_modules/graphql/utilities/astFromValue.js:195:11)
at astFromValue (/Users/xxx/Works/gql/node_modules/graphql/utilities/astFromValue.js:109:26)
at Object.<anonymous> (/Users/xxx/Works/gql/app.js:73:11)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at loader (/Users/xxx/Works/gql/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/xxx/Works/gql/node_modules/babel-register/lib/node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
Here's the code
import { makeExecutableSchema } from 'graphql-tools';
import GraphQLJSON from 'graphql-type-json';
import {
astFromValue,
valueFromAST,
isValidJSValue
} from 'graphql/utilities'
const typeDefs = `
scalar JSON
type MyType {
extra: JSON
}
# ...
`;
const resolvers = {
JSON: GraphQLJSON,
};
var schema = makeExecutableSchema({ typeDefs, resolvers });
var myType = schema.getType('Message'
var value = {
extra: {'key': 'value'}
}
// THIS WILL THROW EXCEPTIONS
astFromValue(value, myType)
Would you please tell me how to fix this? Thanks in advance!
Hi guys,
I'm trying to use this beautiful library in the following code, but it throws an exception:
Here's the code
Would you please tell me how to fix this? Thanks in advance!