graphql-js

Special characters in GraphQL schema

孤者浪人 提交于 2020-01-03 09:03:13
问题 Is there any way of enabling special characters in GraphQL schema (e.g., / , : , @ in the field names)? And if there isn't (which I suspect is the case) do you have an idea what would be relatively easiest way to modify the node.js code (https://github.com/graphql/graphql-js) to achieve such functionality? 回答1: I would recommend against doing in this. graphql-js follows the grammatical form stated in the graphql specification. Such a change would be a break away from the specification and

Special characters in GraphQL schema

我们两清 提交于 2020-01-03 09:03:04
问题 Is there any way of enabling special characters in GraphQL schema (e.g., / , : , @ in the field names)? And if there isn't (which I suspect is the case) do you have an idea what would be relatively easiest way to modify the node.js code (https://github.com/graphql/graphql-js) to achieve such functionality? 回答1: I would recommend against doing in this. graphql-js follows the grammatical form stated in the graphql specification. Such a change would be a break away from the specification and

Explanation for different implementations of resolver function in graphql

一曲冷凌霜 提交于 2020-01-01 19:06:44
问题 I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance. But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains

Explanation for different implementations of resolver function in graphql

心已入冬 提交于 2020-01-01 19:06:29
问题 I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance. But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains

Explanation for different implementations of resolver function in graphql

旧街凉风 提交于 2020-01-01 19:06:29
问题 I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance. But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains

Handling Mongoose Populated Fields in GraphQL

独自空忆成欢 提交于 2020-01-01 01:09:13
问题 How do I represent a field that could be either a simple ObjectId string or a populated Object Entity? I have a Mongoose Schema that represents a 'Device type' as follows // assetSchema.js import * as mongoose from 'mongoose' const Schema = mongoose.Schema; var Asset = new Schema({ name : String, linked_device: { type: Schema.Types.ObjectId, ref: 'Asset'}) export AssetSchema = mongoose.model('Asset', Asset); I am trying to model this as a GraphQLObjectType but I am stumped on how to allow the

GraphQL & Pulling Data from Oracle DB: Query Responds with the Resultset and Doesn't Come to The Graphql resolver Window

怎甘沉沦 提交于 2019-12-25 01:19:17
问题 I am new to GraphQL. Started developing an GraphQL app to pull the data from oracle database. It is very simple application. The query responds with the resultset and can be seen results in console.log ; however, it doesn't come to the graphql window (response/resolver window). It throws the error Cannot return null for non User.email I tried the promise in the oracle connection. Not sure, why it is not showing the data in GraphQL. UserType.js module.exports = new GraphQLObjectType({ name:

GraphQL [graphql js] circular dependencies: The type of * must be Output Type but got: [object Object]

夙愿已清 提交于 2019-12-24 23:43:51
问题 EDIT added my solution as an answer ORIGINAL QUESTION i believe this issue has to do with circular dependencies. i spent the better half of last night and today trying everything i could find online but nothing seems to work. what i have tried: convert the fields prop to a function that returns a field object convert the relating fields (within the fields prop) into functions that return the type combining the two approaches above finally ending with require statements in place of the fields

GraphQL field of type graphql object within an array

坚强是说给别人听的谎言 提交于 2019-12-24 19:31:08
问题 I have a graphQL object defined here: const graphql = require('graphql'); const { GraphQLObjectType } = require('graphql'); const ProductType = new GraphQLObjectType({ name: 'Product', description: 'Product GraphQL Object Schemal Model', fields: { productId: { type: graphql.GraphQLString }, SKU: { type: graphql.GraphQLString }, quantity: { type: graphql.GraphQLFloat }, unitaryPrice: { type: graphql.GraphQLFloat }, subTotal: { type: graphql.GraphQLFloat }, discount: { type: graphql

GraphQL error returning result of mongoose aggregate command

风流意气都作罢 提交于 2019-12-24 16:10:07
问题 This question is related to the answer posted here I need to return an aggregation result from a GraphQL query. Here is the query code: const companiesWithNoUsers = { type: new GraphQLList(CompanyType), resolve(root, args, context) { return Company.aggregate([ { $lookup: { from: "users", localField: "id", foreignField: "company_id", as: "company_users" } }, { $match: { "company_users:0": { $exists: false } } } ]).exec(); } }; I´m getting the follwing error at GraphQL: Expected value of type \