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

Is there anyway to do nested Pick types in Typescript

Similar to Colins answer, but coming at it from the opposite direction. If you have an existing interface/type you need to pick apart you can use indexes: // Existing type type Tenant = { id:string; description:string; name:string; approvedUsers: Array<{ id:string; alias:string; }> } // Pick it apart type TenantManagePageQueryTenant = Pick<Tenant, ‘id’ | ‘description’ | … Read more

What is the purpose of template literals (backticks) following a function in ES6?

These are tagged template literals. The part before the backpacks is a reference to a function that will be called to process the string. The function is passed the variables (the ${} parts) as arguments as well as the pieces of the string that surround the variables broken into an array. The return value of … 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

Using GraphQL Fragment on multiple types

Fragments are only used on the client-side when making requests — they can’t be used inside your schema. GraphQL does not support type inheritance or any other mechanism that would reduce the redundancy of having to write out the same fields for different types. If you’re using apollo-server, the type definitions that make up your … Read more

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

GraphQL : the object name is defined in resolvers, but not in schema

Couple of things to fix here. First, to use an object as an argument, you have to define it as an input (or GraphQLInputObjectType) in your schema — you cannot use a regular type (or GraphQLObjectType) as an argument. So your type definitions need to look something like this: type Mutation { agreementsPost(agreement: Agreement): String … Read more

Support of aggregate function in GraphQL

GraphQL, at the end of the day, responds with your defined types. You just need to put that data into a type. Whether this is a specific type for these different queries, or fields for that data on existing types, it’s up to you but that’s all it boils down to. GraphQL does require more … Read more