The data in my JSON file is not aligning with the parameters in my GraphQL queries

While utilizing graphql-yoga, encountering an issue when executing the 'users' query. Specifically, the error message TypeError: Cannot read properties of undefined (reading 'users') keeps appearing. Despite my attempts at seeking assistance online and from chatgpt, I have been unsuccessful in resolving it.myJsonFile schema.js query.js index.js for resolvers

I am confident that my json file isn't corrupted as I can successfully print it to the console when required. After conducting some research, I suspected that it might be related to context; however, I am unsure how to address this.

Answer №1

After troubleshooting the issue myself, I discovered that the problem originated in server.js. You can see the original state of server.js here. Upon further examination, I realized that when using createYoga, I had only defined the schema without including the context parameter. After making this adjustment and adding my json file to the context, everything started working as intended. You can view the updated version of server.js here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

These JS and Perl scripts may encrypt the same data, but they generate different results. Isn't it expected for them to produce identical output?

Two different programs, one in Javascript and the other in Perl, were designed to accomplish the same task with identical input data. Nevertheless, the output generated by these programs varied. The issue stemmed from using JavaScript on the client side to ...

After modifying the select option, the input field remains disabled

I successfully developed a self-contained code snippet that toggles the enable/disable state of input fields. It works flawlessly on my HTML page. Check it out below: Identification Type: <select name="Identification-Type" id="Identification-Type"& ...

Creating custom JSON fields when serializing objects in Python

I have a problem with serializing objects to JSON in my Python class. class Person(object): def __init__(self,age,name): self.person_age = age self.person_name = name Currently, when I use the code: person = Person(20,'Piter&apo ...

Creating a custom JavaScript library using an existing npm module (codius)

Embarking on a new journey with this, never tried it before. Currently utilizing https://github.com/codius/codius-host. The development of Codiu§ has been abandoned, however I am determined to salvage some parts of it for my own project. It is crucial fo ...

Transmit a JSON array from Javascript to PHP using the POST method

After spending hours searching for a simple solution to send a pre-made JSON string to a PHP method, I finally came across this JavaScript snippet: form = document.createElement("form"), node = document.createElement("input"); var element1 = document.crea ...

Combining two unchangeable objects in JavaScript: A guide

Currently, I'm working on a project using React and Formik. In my validation file, I have exported two validation schema named as `facValidation` and `insValidation`. Here is the content of my `validation.js` file: export const facValidation = Yup.o ...

Guide to retrieving PDFs and images from a Spring Application as an API response and manipulating the data using JS/React

For my current project, I am working on a Spring Boot and React application where I need to create an API that takes the file name as input and returns the file content in Java/Spring Boot. The goal is to display the content in a new browser tab. Below is ...

encountering trouble with reading pathname in React Router DOM due to an error

App.jsx import { useState } from 'react'; import './App.css'; import NewsContainer from './Components/NewsContainer'; import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; function App() { const [mode, ...

The modal is not displayed when the on click listener is triggered

I'm a beginner in the world of programming and I'm currently working on creating modals that pop up when clicked. However, I'm facing an issue where the pop-up message doesn't appear when I click the button. Oddly enough, only the overl ...

Using CSS to customize the appearance of the preview in CKEditor

After successfully integrating CKEditor into my website CMS, I am facing an issue with the Preview button not using stylesheets (CSS). Despite editing the preview.html file located in: Website/ckeditor/plugins/preview/ It appears that the CSS is being ig ...

Obtaining the Div ID After Clicking on a Link

I'm attempting to fade out a box once the X in that box is clicked. I haven't been able to make it work even after searching on Google. I managed to get it working when clicking the div itself using $(this), but my goal is for it to work when the ...

Adjusting the width of the search bar in a Bootstrap inline form

Issue: The search box is not resizing with the page and I can't figure out how to make it wider. Adding styles like width: 100%; hasn't worked so far. In addition, the select dropdown box in the image linked below appears slightly clipped on the ...

What is the process for retrieving matched information from a drop-down menu in HTML?

Is there a way to retrieve data from angularjs like this: This is the list of data I need to access: $scope.orderStatus = [ { os: 'Open', value: 1 }, { os: 'Completed', value: 2 }, { os:'Cancelled',value: 3 }, ...

A guide on how to activate an event when a radio button is selected using jQuery

I experimented with implementing this. When I try clicking on the radio button, the code functions correctly, but the radio button does not appear to be checked and remains unchanged. Any ideas on how to resolve this issue? <p> <input id="p ...

Unable to modify textures with a click on threejs

I am attempting to change the textures and colors of an object when clicking on separate cubes. I have encountered a challenge where I can only change the color of the object once, even when using a for-loop, and only if there are no previous textures or c ...

Creating a selection component in ReactJS populated with data fetched from Axios

I'm attempting to retrieve data using axios, and here's the code I've created: const fetchContactList = () => { var data = { "list_id": `${myListID}`, }; const headers = { 'Content-Type': 'applic ...

What is the best way to simulate a service that returns a promise when writing unit tests for AngularJS using Jasmine?

I have a service named myService that relies on another service called myOtherService. The latter makes a remote call and returns a promise. Here's the implementation: angular.module('app.myService', ['app.myOtherService']) .fac ...

Tips for transferring information in JavaScript games

While browsing an HTML-based website, I am able to send POST and GET requests. However, in a JavaScript game like agar.io, how can similar actions be performed? Specifically, when playing a popular game like agar.io, how is my game state (such as positio ...

What is the process for updating npm on a Windows operating system?

Seeking advice on upgrading my npm version, I attempted Option 3 for Windows as outlined in the npm documentation. However, upon installation, I received a message stating that npm.exe already exists in the nodejs folder. Despite trying to overwrite it u ...

Barely populated React application following setup

I have been diving into React for quite some time now. However, today when I attempted to start a new project, it generated an almost empty project. My usual command create-react-app 'name-of-my-app' was used. It ran for a while and completed th ...