GraphQL-Express | An Express Server implemented using GraphQL | GraphQL library
kandi X-RAY | GraphQL-Express Summary
kandi X-RAY | GraphQL-Express Summary
An Express Server implemented using GraphQL
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of GraphQL-Express
GraphQL-Express Key Features
GraphQL-Express Examples and Code Snippets
Community Discussions
Trending Discussions on GraphQL-Express
QUESTION
I am setting up my first GraphQL endpoint with graphql and graphql-express. My MongoDB schema has two types: User and Card, where a User can have many Cards. I set up the root types and resolvers with no issues. I can query and mutate users and cards in the database.
My problem comes when I try to nest cards in users, and I get Error: Expected undefined to be a GraphQL type
. The error only appears when I set UserType.fields.cards.type
to be an instance of graphql.GraphQLList
, yet I had an identical field
value in QueryType.js, and that works fine.
Looking at other questions on Stack Overflow, it appears that my problem could be a cyclical reference between my User and Card types, but I am struggling to find any problems in my code. Is there something I'm missing here?
The full stack trace is:
...ANSWER
Answered 2020-Dec-06 at 18:03In UserType.js, I destructured the output of require('./CardType')
which resulted in CardType
being undefined. GraphQLList
expected an instance of GraphQLObjectType but instead received undefined, hence the error.
QUESTION
I need help interpreting a piece of code.
I have been attempting to learn how to authenticate users with jwt and returning tokens and refresh tokens.
It has been a fun ride and I came across this repository where the user added an extension/chain function which as far as I understand combines multiple graphql resolvers:
...ANSWER
Answered 2020-Mar-31 at 20:55I've taken the liberty of renaming some things, because the existing names are very confusing.
QUESTION
I wish to test that my Express server launches properly and that my endpoint retrieves the correct information. I wish to do this in CI so that I can monitor when my application is no longer working, if I make any changes in the future.
It's a very simple application, my server looks like this:
server.js
ANSWER
Answered 2019-Jul-23 at 17:03npm start &
won't wait for server to start, are you sure your server is listening on the port by the time your test makes a request? I.e. do you have 'Server running on port: 1337'
in your console on CI? If not then try running sleep 3
before starting tests
QUESTION
I am using the graphql-express lib to build a small proof of concept GraphQL server. Let's assume this schema:
...ANSWER
Answered 2019-Apr-08 at 08:57Resolvers let you define functions that will get executed only when a field is requested.
So we can define function on the Book
type for author and on Author
type for books, lets assume that author field contains author id and books contains array of book ids
QUESTION
I'm following the tutorial here: Implementing GraphQL Using Apollo On an Express Server and I'm getting the error GET query missing in the browser at http://localhost:7700/graphql.
First I typed all the code myself. When I encountered the error, I downloaded the code from GitHub: kimobrian/GraphQL-Express: An Express Server implemented using GraphQL to eliminate the possibility that I had made a mistake. However, I'm still getting the same error.
I presume it is better to provide the link to the repo rather than paste the code here because I'm using the same code from the repo. Also, I am not sure which file might contain the problem.
...ANSWER
Answered 2019-Jan-19 at 13:02Both the API and the package name itself have changed since that tutorial was written (the package is now apollo-server-express
). You no longer need to import cors
or body-parser
. The simplest way to get started is to actually just use apollo-server:
QUESTION
Webstorm 2018.3/Windows 10
v8.0.0/6.4.1
JetBrains ECMAScript6 in Webstorm Babel FileWatcher
I added
Babel
through the stepsFor a local repository I installed
npm i --save-dev @babel/cli @babel/core @babel/preset-env @babel/plugin-object-proposed-rest-spread
added
....babelrc
in the root folder with following:
ANSWER
Answered 2019-Jan-03 at 23:40I stripped down your example and added a minimal version of what you need to get it up and running.
Basically what you're missing is the part where babel actually goes and transpiles your code. I don't know if webstorm does that for you, I'm using VS code.
.babelrc:
QUESTION
I am just getting my hands dirty with GraphQL using Express. I am following the Academind YouTube Series for GraphQL-Express-Node-React. I have just setup a basic GraphQL Schema where I have hardcoded Array of Strings which is returned. I want to create a Query which gives me the index of the element from this hardcoded array using GraphQL (graphiql
)
ANSWER
Answered 2019-Jan-03 at 13:59This error is not specific to GraphQL.
Array.findIndex expects a function to be passed in as its first parameter. The function is called for each element in the array until the function returns a truthy value, at which point it returns the index of that element. The value of args.eventName
is not a function (it's a String) so you end up with that error.
Either pass it a function, like:
QUESTION
I am getting an error which says " Error: Expected undefined to be a GraphQL schema." Please check what issue is this when I move to localhost:3000/graphiql it shows the above error. Maybe i am doing some mistake please anyone check and help me if possible.
My Server.js
...ANSWER
Answered 2018-Nov-07 at 15:51You're not passing in a schema to your configuration for the /graphql
endpoint. Property names are case-sensitive in javascript. Change this:
QUESTION
I am following a tutorial which uses mongo database with graphql, currently the tutor uses apollo-server v1 but I am using apollo-server v2, the problem I'm having is where do i make the connection of my models to graphql,
...ANSWER
Answered 2018-Aug-20 at 12:26This example works perfect with PG, if you are using Mongo, just replace pg calls with mongoose and you should be good to go.
QUESTION
I'm creating a Reddit clone and I'm setting up the backend first, but having trouble creating relational data.
When I use this query:
...ANSWER
Answered 2018-May-24 at 13:45Move the resolver you have written for Query
's posts
into Subreddit
to resolve the posts field there. If your resolver does not comply to the default resolver implementation:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install GraphQL-Express
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page