Stitching secure subscriptions using makeRemoteExecutableSchema

I have one working solution: the idea is to not create one instance of SubscriptionClient for the whole application. Instead, I’m creating the clients for each connection to the proxy server: server.start({ port: 4000, subscriptions: { onConnect: (connectionParams, websocket, context) => { return { subscriptionClients: { messageService: new SubscriptionClient(process.env.MESSAGE_SERVICE_SUBSCRIPTION_URL, { connectionParams, reconnect: true, }, ws) … Read more

How to parse GraphQL request string into an object

You can use graphql-tag : const gql = require(‘graphql-tag’); const query = ` { qQueryEndpoint { id } } `; const obj = gql` ${query} `; console.log(‘operation’, obj.definitions[0].operation); console.log(‘name’, obj.definitions[0].selectionSet.selections[0].name.value); Prints out : operation query name qQueryEndpoint And with your mutation : operation mutation name saveSomething

What is the difference between apollo server and express-graphql

Below is the now deleted section from the apollo-server README comparing apollo-server to express-graphql. Note that some of these arguments do not apply anymore e.g. express-grapqhl is now written in TypeScript. Hence the removal of this section from the README. One observation is that apollo-server is too bloated, and is slowly showing a lack of … Read more

How to load a .graphql file using `apollo-server`?

If you define your type definitions inside a .graphql file, you can read it in one of several ways: 1.) Read the file yourself: const { readFileSync } = require(‘fs’) // we must convert the file Buffer to a UTF-8 string const typeDefs = readFileSync(require.resolve(‘./type-defs.graphql’)).toString(‘utf-8’) 2.) Utilize a library like graphql-tools to do it for … Read more

How do I handle deletes in react-apollo

I am not sure it is good practise style but here is how I handle the deletion of an item in react-apollo with updateQueries: import { graphql, compose } from ‘react-apollo’; import gql from ‘graphql-tag’; import update from ‘react-addons-update’; import _ from ‘underscore’; const SceneCollectionsQuery = gql ` query SceneCollections { myScenes: selectedScenes (excludeOwner: false, … Read more

Why am I getting a “Cannot return null for non-nullable field” error when doing a mutation? [duplicate]

The biggest problem with your resolver is that in any number of scenarios, instead of returning a User object, you return a string. Your schema specifies that createAccount can return a User or null (if it was User!, it would be non-nullable and then null would not be a valid type either). When you return … Read more

How do I add a description to a field in “GraphQL schema language”

If you’re using GraphQL.js version 0.7.0 or above, you can simply add a comment directly before the field, type, or argument you want to describe. For example: # A type that describes the user type User { # The user’s username, should be typed in the login field. username: String! # The user’s password. password: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)