graphql-js

GraphQL Expected Iterable, but did not find one for field xxx.yyy

帅比萌擦擦* 提交于 2019-11-26 18:15:13
问题 I'm currently trying GraphQL with NodeJS and I don't know, why this error occurs with the following query: { library{ name, user { name email } } } I am not sure if the type of my resolveLibrary is right, because at any example I had a look at they used new GraphQL.GraphQLList() , but in my case I really want to return a single user object, not an array of users. My code: const GraphQL = require('graphql'); const DB = require('../database/db'); const user = require('./user').type; const

Field \“me\” of type \“User\” must have a selection of subfields

末鹿安然 提交于 2019-11-26 14:43:49
问题 Hi I am trying to learn GraphQL language. I have below snippet of code. // Welcome to Launchpad! // Log in to edit and save pads, run queries in GraphiQL on the right. // Click "Download" above to get a zip with a standalone Node.js server. // See docs and examples at https://github.com/apollographql/awesome-launchpad // graphql-tools combines a schema string with resolvers. import { makeExecutableSchema } from 'graphql-tools'; // Construct a schema, using GraphQL schema language const

GraphQL Blackbox / “Any” type?

喜夏-厌秋 提交于 2019-11-26 14:40:33
Is it possible to specify that a field in GraphQL should be a blackbox, similar to how Flow has an "any" type? I have a field in my schema that should be able to accept any arbitrary value, which could be a String, Boolean, Object, Array, etc. @mpen's answer is great, but I opted for a more compact solution: const { GraphQLScalarType } = require('graphql') const { Kind } = require('graphql/language') const ObjectScalarType = new GraphQLScalarType({ name: 'Object', description: 'Arbitrary object', parseValue: (value) => { return typeof value === 'object' ? value : typeof value === 'string' ?

Notable differences between buildSchema and GraphQLSchema?

喜欢而已 提交于 2019-11-26 04:26:24
问题 Are there any notable differences between the two? Im interested in anything from runtime and startup performance to features and workflow differences. Documentation does a poor job on explaining the difference and when I should use one over the other. Example in both versions: buildSchema const { graphql, buildSchema } = require(\'graphql\'); const schema = buildSchema(` type Query { hello: String } `); const root = { hello: () => \'Hello world!\' }; graphql(schema, \'{ hello }\', root).then

Why does a GraphQL query return null?

佐手、 提交于 2019-11-25 22:15:44
问题 I have an graphql / apollo-server / graphql-yoga endpoint. This endpoint exposes data returned from a database (or a REST endpoint or some other service). I know my data source is returning the correct data -- if I log the result of the call to the data source inside my resolver, I can see the data being returned. However, my GraphQL field(s) always resolve to null. If I make the field non-null, I see the following error inside the errors array in the response: Cannot return null for non