express-graphql

After installing graphql-tools and graphql-express. Error message in console 'Cannot find name 'AsyncIterator'

眉间皱痕 提交于 2019-12-11 13:36:49
问题 Error Log On initiating application While initiating the application it shows the following error and i tried couple of fixes from online which has mentioned below but none of them has worked requesting for suggestions and solutions node_modules/@types/graphql/subscription/subscribe.d.ts(17,12): error TS2304: Cannot find name 'AsyncIterator'. node_modules/@types/graphql/subscription/subscribe.d.ts(29,12): error TS2304: Cannot find name 'AsyncIterable'. node_modules/graphql-tools/dist

How to write graphql query wiith custom objects

眉间皱痕 提交于 2019-12-11 04:14:30
问题 The server side of graphql is with nodejs and express. This is the schema for graphql. It has one query which accepts DateT object having from and to dates. var schema = buildSchema(` type Query { courseWithDate( timeFilter: DateT ): Course }, type Course { ... from: String to: String }, type DateT{ from : String to : String } `); and this is how I am getting courses I am able to run the application with this url localhost:4000/graphql This is the query I am using query courseWithDate($from:

Unexpected <EOF> while using graphql

空扰寡人 提交于 2019-12-08 17:19:11
问题 Getting EOF error every time at same line, changed code many times and even degraded to previous versions of graphql but no positive results. My code is: const graphql = require('graphql') const _ = require('lodash') const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLSchema } = graphql const users = [ {id: '1', firstName: 'Ansh', age: 20}, {id: '2', firstName: 'Ram', age: 21}, {id: '3', firstName: 'Sham', age: 20} ] const UserType = new GraphQLObjectType({ name: 'User', fields: { id

GraphQL: Non-nullable array/list

谁说我不能喝 提交于 2019-12-04 17:26:10
问题 I'm learning GraphQL now and while walking through tutorial I met behavior that I can't understand. Let's say we have defined type in schema: type Link { id: ID! url: String! description: String! postedBy: User votes: [Vote!]! } Due to docs votes: [Vote!]! means that that field should be a non-nullable and array itself should be non-nullable too. But just after that author of tutorial shows example of query and for some of links it returns empty array for votes field. Like this: { "url":

Is it possible to fetch data from multiple tables using GraphQLList

…衆ロ難τιáo~ 提交于 2019-12-04 06:22:05
问题 In GraphQL we can write the object type in GraphQLList and fetch all the fields. I am using Association and it is joining the two tables but I am unable to fetch the field of both the tables. It only takes the fields what I have written in GraphQLList.As I want the list of data. Here is the code films table: module.exports =(sequelize, DataTypes) => { const films = sequelize.define( 'films', { id:{ type: DataTypes.INTEGER, primaryKey: true, allowNull: false, }, name: { type: DataTypes.STRING,

GraphQL returning null data from axios [duplicate]

梦想的初衷 提交于 2019-11-29 13:08:07
This question already has an answer here: Why does a GraphQL query return null? 1 answer I am writing a GraphQL server in Node.js and Express. I have a JSON file of data and so I am using Axios to query data from that JSON file and pass it to GraphQL query, const RootQuery = new GraphQLObjectType({ name:'RootQueryType', fields: { holiday: { type: Holiday, args:{ date:{type:GraphQLString}, }, resolve(parentValue, args) { return axios.get('http://localhost:3000/holidays?date='+ args.date).then(res => res.data); } }, On console.log(res.data) , I am getting the data, however, on querying by date

How to access the value of parent resolver inside a field resolver while using buildSchema?

限于喜欢 提交于 2019-11-28 14:35:38
When we are using graphqlHTTP, the first argument passed to the resolve method is actually the parameters passed by the client query not root this is fine for a query resolver. But for a usecase where field resolver needs to know of a value of the parent, how to achieve this? type Person { name: String, cityId: String, city: City, } In the above scenario I would like where city would be a field resolver, and it needs access to cityId which is a property on parent type. I assume this should have been passed as parameter to the field resolver but that is not the case. Is there a way to achieve

GraphQL returning null data from axios [duplicate]

萝らか妹 提交于 2019-11-28 06:41:48
问题 This question already has an answer here: Why does a GraphQL query return null? 1 answer I am writing a GraphQL server in Node.js and Express. I have a JSON file of data and so I am using Axios to query data from that JSON file and pass it to GraphQL query, const RootQuery = new GraphQLObjectType({ name:'RootQueryType', fields: { holiday: { type: Holiday, args:{ date:{type:GraphQLString}, }, resolve(parentValue, args) { return axios.get('http://localhost:3000/holidays?date='+ args.date).then

How to access the value of parent resolver inside a field resolver while using buildSchema?

一世执手 提交于 2019-11-27 04:49:08
问题 When we are using graphqlHTTP, the first argument passed to the resolve method is actually the parameters passed by the client query not root this is fine for a query resolver. But for a usecase where field resolver needs to know of a value of the parent, how to achieve this? type Person { name: String, cityId: String, city: City, } In the above scenario I would like where city would be a field resolver, and it needs access to cityId which is a property on parent type. I assume this should