Apollo Server Studio is failing to detect the schema configured in Apollo setup

Here is the stack I'm working with:

Apollo Server, graphql, prisma, nextjs

I've set up a resolver.ts and schema.ts for my graphql configuration under /graphql

resolver.ts

export const resolvers = {
  Query: {
      books: () => books,
    },
  };


const books = [
    {
      title: 'The Awakening',
      author: 'Kate Chopin',
    },
    {
      title: 'City of Glass',
      author: 'Paul Auster',
    },
  ];

schema.ts

import { gql } from "apollo-server-micro";

export const typeDefs = gql`

  # This "Book" type defines the queryable fields for every book in our data source.
  type Book {
    title: String
    author: String
  }

  # The "Query" type is special: it lists all of the available queries that
  # clients can execute, along with the return type for each. In this
  # case, the "books" query returns an array of zero or more Books (defined above).
  type Query {
    books: [Book]
  }

/pages/api/graphql.ts

// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { ApolloServer } from 'apollo-server-micro';
import { typeDefs } from '../../graphql/schema';
import { resolvers } from '../../graphql/resolver';

const apolloServer = new ApolloServer ({typeDefs, resolvers});
const startServer = apolloServer.start();

export default async function handler(req, res) {
  res.setHeader('Access-Control-Allow-Credentials', 'true');
  res.setHeader(
    'Access-Control-Allow-Origin',
    'https://studio.apollographql.com'
  );
  res.setHeader(
    'Access-Control-Allow-Headers',
    'Origin, X-Requested-With, Content-Type, Accept'
  );
  if (req.method === 'OPTIONS') {
    res.end();
    return false;
  }
  await startServer;
  await apolloServer.createHandler({
    path: "/api/graphql",
  })(req, res);
}

export const config = {

  api: {
    bodyParse: false
  }

}

When I access my api endpoint /api/graphql it redirects me to the apollo studio explorer but fails to recognize the endpoint or the schema. The errors shown in the development tools don't provide much insight:

StaleWhileRevalidate.js:112 Uncaught (in promise) no-response: no-response :: [{"url":"https://cdn.segment.com/analytics.js/v1/xPczztcxJ39mG3oX3wle6XlgpwJ62XAA/analytics.min.js"}]
    at O._handle (https://studio.apollographql.com/service-worker.js:2:71211)
    at async O._getResponse (https://studio.apollographql.com/service-worker.js:2:47966)
_handle @ StaleWhileRevalidate.js:112
useTelemetryInitializer.ts:174          GET https://cdn.segment.com/analytics.js/v1/xPczztcxJ39mG3oX3wle6XlgpwJ62XAA/analytics.min.js net::ERR_FAILED

I suspect the issue does not pertain to prisma as I have only configured a postgresql database and defined some basic schema. It's unclear why the studio isn't recognizing my endpoint, and there are no cross-origin errors suggesting a CORS issue.

Studio screenshot:

https://i.sstatic.net/UYmRM.png

Answer №1

Apologies if it's past the deadline, but what ultimately resolved the issue for me was clearing out the website's storage.

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

Accessing a JSON string correctly using JavascriptSerializer in JavaScript

When working with JavaScript, I encountered an issue where the data retrieved from a data table and converted to javascriptSerializer was not refreshing correctly when changing dataset selection parameters. The problem occurred when trying to populate a ne ...

Encountering Server Error 500 while trying to deploy NodeJS Express application on GCP App Engine

My goal is to deploy a NodeJS app on gcloud that hosts my express api. Whenever I run npm start locally, I receive the following message: >npm start > [email protected] start E:\My_Project\My_API > node index.js Running API on por ...

The body classList variable is inaccurately updated when making a JQuery Ajax call

Currently, I am in the process of developing a script to manage Ajax page transitions using JQuery's Ajax request function. Within the success callback of the Ajax function, it is essential for me to access the classList of the current page's bod ...

Can you explain how to break down secured routes, users, and posts all within a single .create() function in Mongoose/JavaScript

I am seeking guidance on utilizing the .create() method within a protected route while implementing deconstructed JavaScript. In the absence of the protected route, I can deconstruct my schema and utilize req.body in .create(...) as shown below. const { ti ...

When attempting to access a static method in TypeScript, an error occurs indicating that the property 'users_index' does not exist on the type 'typeof UserApiController'

Just dipping my toes into TypeScript and attempting to invoke a function on a class. In file A: import userAPIController from "./controllers/customer/userAPIController"; userAPIController.users_index(); In file B: export default class UserApiControlle ...

"Transforming Selections in Illustrator through Scripting: A Step-by-Step Guide

In Illustrator, I successfully used an ExtendScript Toolkit JavaScript code to select multiple elements like text, paths, and symbols across different layers. Now, I am looking to resize them uniformly and then reposition them together. While I can apply ...

"Implementing a dynamic image thumbnail list with adjustable opacity effects and the ability to add or remove classes

I found a script on another post, but it's not working correctly in my implementation. Everything is functioning properly except that the "selected" class is not being stripped, causing the thumbnails to remain highlighted after being clicked. Here is ...

Press on a specific div to automatically close another div nearby

var app = angular.module('app', []); app.controller('RedCtrl', function($scope) { $scope.OpenRed = function() { $scope.userRed = !$scope.userRed; } $scope.HideRed = function() { $scope.userRed = false; } }); app.dire ...

Is there a way to create a self-contained installation package for my Vue application?

Is it possible for my application to be downloaded and installed without requiring internet access after the download is complete? I am looking to create a standalone installer for this purpose. Are there any suggestions on how to go about implementing t ...

What is the proper way to connect with the latest Set and Map objects?

Can Angular 1.* ng-repeat function with Set and Map new objects? Is there a roadmap to implement this integration? ...

Finding the scope of dynamically generated fields in AngularJS has proven to be quite challenging

I'm currently working on creating a dynamic form where users can add input fields by clicking a button. However, I am facing issues with fetching the value of the input field in the controller. Below is my form: <div ng-repeat="skill in skill_set" ...

Refresh the table following the removal of an item

I am currently working on displaying server data in a table. The delete function is functioning properly, but the deleted item only disappears from the table after refreshing the page. Is there a way to trigger a re-render of the component after deleting a ...

Checking for the existence of an object while passing variables in jade - a comprehensive guide

Leveraging the power of Jade, passing an object to the client can be achieved in this way: Route: res.render('mypage', { title: 'My Page', myobject : data }); Jade Template: extends layout block navbar include includes/navbar ...

Design for implementing "new" functionality in JavaScript

I recently delved into the world of JavaScript Patterns through Stoyan Stefanov's book. One pattern that caught my attention involves enforcing the use of the new operator for constructor functions, demonstrated with the following code snippet: funct ...

Testing reactive streams with marble diagrams and functions

Upon returning an object from the Observable, one of its properties is a function. Even after assigning an empty function and emitting the object, the expectation using toBeObservable fails due to a non-deep match. For testing purposes, I am utilizing r ...

I'm having trouble making a Javascript ajax request to my Web API controller page. It seems like I just can't figure out the correct URL

Currently, I am facing an issue with my registration page where I am attempting to save input fields into a new record in the Users table. <button class="btn-u" type="submit" onclick="submitclicked()">Register</button> The click event trigger ...

Synchronizing information between different controllers using a service

After reading the discussion on this stackoverflow post, it seems like using services is the recommended way to transfer data between controllers. However, in my own testing on JSFiddle here, I encountered difficulties in detecting changes to my service w ...

Issues with integrating VUE frontend with PHP backend and API

Apologies for any language mistakes as English is not my native tongue. I hope my message is clear enough. We are in the process of developing a user system where users, upon logging in, can perform various actions such as joining events, updating their p ...

Implement a vertex shader to transform a mesh's vertices without consideration of its current location

Looking to add movement to my meshes using a vertex shader, I've run into an issue where translating my meshes in the scene also affects the position of a sinus wave. The goal is to keep the sinus wave consistent across both meshes even when translati ...

The combination of React.js and debouncing on the onChange event seems to be malfunctioning

I recently incorporated a React component that triggers an event on change. Here's how I did it: NewItem = React.createClass({ componentWillMount: function() { this._searchBoxHandler = debounce(this._searchBoxHandler, 500); }, _searchBoxH ...