Apollo-Server | Apollo Server - | GraphQL library
kandi X-RAY | Apollo-Server Summary
kandi X-RAY | Apollo-Server Summary
Apollo-Server
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 Apollo-Server
Apollo-Server Key Features
Apollo-Server Examples and Code Snippets
Community Discussions
Trending Discussions on Apollo-Server
QUESTION
So I have an Express / TypeGraphql backend running at localhost:5000
and Next / React app running at localhost:3000
. I decided to use apollo-server for graphql API and apollo-client for the front end. After a successful login, I store httpOnly cookies in web browser.
What I want to do is, get cookies in every request and authorize the user if oauth2 tokens are valid. Even though requests are valid, and I get the query, cookies are shown as null. Also, I got no error in the console.
Here I save cookies =>
server.ts ...ANSWER
Answered 2021-Jun-09 at 09:20I think you have not fully understood Next.js yet. Next.js renders views on the server or alternatively sends "server side props" to the client. This means getServerSideProps
gets executed on the server (as the name suggests). Cookies are a feature of the browser. So what happens?
- Browser sends request to Next.js. If your Next.js server and your GraphQL server are on the same domain, the request includes the Cookie header.
- Next.js receives request and executes
getServeSideProps
. - Next.js Apollo Client makes request to server, missing the cookies, because the cookies are only in the browser's initial request!
This means you would have to first make sure that your Next.js server receives the cookies from the frontend. This should happen automatically, if it is on the same origin as the GraphQL server. Otherwise it is a bit tricky and it should be easier to work with an explicit Authorization header in this case. Then you have to pass on the cookies with the request. This can be done by accessing req
in getServerSiteProps
and using the context
in client.query
.
QUESTION
I am trying to use import { applyMiddleware } from 'graphql-middleware';
library to add validation middleware on mutation's input.
So, I created a sample middleware function which is log input
...ANSWER
Answered 2021-Jun-07 at 09:22It's strange but the problem was with this import { GraphQLDateTime } from 'graphql-iso-date';
package.
After removing it from the schema, it started working.
QUESTION
I am trying to generate user id using uuid npm package for the id field in the user type. I am not sure where and how should I write it.
In my createUser mutation I am only asking the user to put in values for the name and email but not the id, as I wanted it to be generated by the uuid package, which is what I believe I have done it correctly in the createUser mutation.
Here is what I have in my schema.graphql file
...ANSWER
Answered 2021-Jun-05 at 05:07A UUID is not an Int
, so your Prisma schema of id Int @id @default(autoincrement())
does not make sense if you want to use a UUID. Same for your parseInt
call. If you want to use a UUID, then you would need
QUESTION
I saw this statement in Graphql directive definition:
...ANSWER
Answered 2021-Jun-04 at 23:25That means if field
contains a resolve
property, extract it:
QUESTION
I've got a problem in my NestJs app. Project was running perfect until yesterday.
Apparently my node.js upgraded from 14.16.1
to 14.17.0
. So I changed this version number in my engines
object, in package.json
. I executed yarn install
again, to make sure everything was there, and tried yarn start:dev
(which translates to nest start --watch
).
But my app isn't running =( It seems like there's something wrong regarding my apollo-server-fastify:
...ANSWER
Answered 2021-Jun-01 at 05:58A temporary fix, until this issue is addressed by maintainers, is to copy this patch file into your repository, then modify your package.json to use the following:
"@nestjs/graphql": "patch:@nestjs/graphql@7.10.6#[YOUR/LOCAL/PATH]/graphql.patch"
I ran into this same issue with my project. I'm not sure about the origin, but I did see that apollo-server-fastify
was updated to 3.0.0-lambda.0 about 5 days ago and to 3.0.0-preview.0 a few hours ago.
I tracked the possible fix down to the registerFastify
method in @nestjs/graphql
. The solution, I believe, is to call await apolloServer.start()
on line 228 in lib/graphql.module.ts
before the Apollo Server's createHandler()
method is called. I opened an issue on the repository with more details, which you can follow until resolved.
I implemented the fix in the template repository I'm working on with yarn patch @nestjs/graphql
. The repository is available on the dev-nx
branch at troncali/nest-vue. The patch is located in ./.yarn/patches/@nestjs/graphql.patch
.
QUESTION
I'm trying to make an _id
field based off the title for topic
object I've defined in my server. Here's the the schema.
ANSWER
Answered 2021-Jun-03 at 17:33Because you haven't declared your _id
on your Mongoose Schema, Mongoose is defaulting to an ObjectId
type for your documents' _id
instead of a String
one that leads to the error.
To solve this you can declare the _id
in your schema like this:
QUESTION
I'm trying to write a NPM package with some React
stuff included, at the moment it's just a component and a hook. To build the package I'm using Webpack. I've added react
and react-dom
to the externals section to ensure that it's not included in the bundle. I've also marked react
as a peerDependency
in the package.json
and included it as a devDependency
. Still I'm getting the error Invalid hook call
when trying to use the bundle in another project. I think I've tried everything that I can Google my way to (like using the package with the purpose to solve this) with no luck.
My Webpack config looks like this at the moment:
...ANSWER
Answered 2021-May-31 at 19:50Thanks for all the help!
The issue was that I stopped publishing packages and instead installed the dependency locally using file:../Client
. That caused duplicate instances of React
since it used the local-to-the-Client-package instance of React
. Publishing only the built output and then installing that dependency solved the issue for me.
I found the following answer helpful for me to realize this (linking the react dependency between the two packages) if anyone else stumbles upon this.
QUESTION
It appears that GraphQL-queries with sort are broken on Neo4j Aura.
A GraphQL call that was working for months now suddenly fails.
The main error message that comes back is: Neo4jError: Unknown function 'apoc.coll.sortMulti'
Queries that fail have this shape:
...ANSWER
Answered 2021-May-27 at 19:41Yes, a problem with a buggy APOC jar in the latest Aura push. I believe all apoc.coll functions and procs may be affected.
It's being worked on, you can monitor status here:
QUESTION
I am trying to implement permission guards in a graphql backend using apollo server. The following code works:
Resolvers
ANSWER
Answered 2021-May-24 at 19:12Based off your code, it seems like you're looking for making isOwner
a higher-order function, so that you can pass in the collection, and it returns
the curried method.
QUESTION
I'm using type-graphql in conjunction with typeorm, apollo-server-express and postgreSQL. I have a User and a Customer entity in a 1:n relationship, meaning one user can have multiple customers.
I can create users and customers just fine, but when attempting to retrieve the user associated to a customer using Apollo Server playground, I get an error message stating "Cannot return null for non-nullable field Customer.user."
When I check the database, the associated user id on the customer table is definitely not null (see attached image).
...ANSWER
Answered 2021-May-17 at 11:25In your resolver change the find
operation like below:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Apollo-Server
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