Tag: Node.Js
-
How do I use web socket inside a graphql mutation using socket.io and expressGraphQL?
0 `I have been trying to emit an event to a specific user using socket.io when a specific mutation is called I tried to use this on my main server file: const graphqlMiddleware = expressGraphQL((req, res) => ({ schema, graphiql: __DEV__, rootValue: { request: req, response: res, }, pretty: __DEV__, })); app.use("/graphql", graphqlMiddleware); let server…
-
Correctly cast “unknown” into type in Typescript
0 I am using the graphql-request library to fetch data froma GraphQL endpoint. The endpoint returns some information about a user, based on a certain token associated to that user. Here is the type I’ve defined: export type PlayerInfo = { country: string, name: string|undefined, email: string, id: string, } Here are the two approaches…
-
Argument passed into graphql mutation is always undefined
0 Learning graphql, cannot get mutation to work yet, get lost on the online examples. import express from ‘express’ import cors from ‘cors’ import { graphqlHTTP } from ‘express-graphql’ import { makeExecutableSchema } from ‘@graphql-tools/schema’ const app = express() const port = 4000 // In-memory data store const data = { warriors: [ { id:…
-
Correctly coerce “unknown” GraphQL response into type
0 I am using the graphql-request library to fetch data froma GraphQL endpoint. The endpoint returns some information about a user, based on a certain token associated to that user. Here is the type I’ve defined: export type PlayerInfo = { country: string, name: string|undefined, email: string, id: string, } Here are the two approaches…
-
I’m getting an error when I try to upload in GraphQL: “POST body missing, invalid Content-Type, or JSON object has no keys.”
0 My code is correct, but I don’t know what’s happening, I need to upload it with graphQL but I can’t, my resolver code looks like this: `import { Resolver, Query, Mutation, Arg } from "type-graphql"; import { GraphQLUpload, FileUpload } from "graphql-upload-ts"; @Resolver() export class CategoryResolver { @Mutation(() => String) async uploadImage(@Arg("file", () =>…
-
Malformed Cursor (shopify graphql api query)
0 I am trying to fetch collections (paginated) from my shopify store using graphql query, i have written this route: async function (req: CustomRequest, res: Response) { const shopUrl: string = req.shopUrl || “”; const accessToken: string = req.accessToken || “”; let { count, after }: any = req.query; const params = new URLSearchParams(); if(!count){…
-
Node.js, Apollo Server v4, GraphQL, Mongoose – Category Tree
1 I am trying to create Category Tree with Node.js, Apollo Server v4, GraphQL, Mongoose technologies. But when I want to get the created Category or Subcategory data, the output is not what I want. Categories appear both in subCategories as a reference and as a normal category. I also added category data with this…
-
Node.js, Apollo Server, GraphQL, Mongoose – Category Tree
0 I am trying to create Category Tree with Node.js, Apollo Server, GraphQL, Mongoose technologies. But when I want to get the created Category or Subcategory data, the output is not what I want. Output; { "data": { "getCategories": { "success": true, "response_code": "categories-successfully-retrieved", "message": "Categories Successfully Retrieved!", "categories": [ { "_id": "655a1b6018951b0985fd7635", "name": "K…
-
MySQL query data returns null GraphQL node.js
0 I’m having trouble handling MySQL query data in the resolve function of GraphQL objects. The data returns null in GraphiQL despite printing with console.log(). I’ve tried using JSON.parse(). I have the following code: Schema.js const graphql = require(‘graphql’); const queries = require(‘../mysql/queries’); const { GraphQLObjectType, GraphQLString, GraphQLSchema, GraphQLID, GraphQLInt, GraphQLFloat, GraphQLList, GraphQLNonNull } =…
-
use nexus-prisma without prisma client
0 I am planning on using prisma for building the database and migrations, I am not going to use prisma client as there are some limitations I am hitting since prisma does not use native joins. I also want to use nexus prisma to auto generate types for my graphql api. However, I see that…