Graphql Relay Mutation with serverside validation

I am trying to code a relay mutation that will allow server side validation. Such as a record with that name already exists. Below is my GraphQL mutation. /* @flow weak */ import {mutationWithClientMutationId,offsetToCursor} from "graphql-relay"; import {GraphQLString, GraphQLList, GraphQLNonNull} from "graphql"; import NominationConnection from '../NominationsConnection'; import ViewerType from '../../../types/ViewerType'; import Helper from '../../../helper/helper'; import Nomination from

Graphql Cannot set property 'clientMutationId' of undefined" Error

outputfields never gets called, not sure whether i am doing in a right way or not, doesn't the resolve function gets called while returning data from mutateAndGetPayload method. mutateAndGetPayload: (credentials) => { console.log('credentials', credentials); userprof.findOne({email:}).exec(function(err, r) { if(!r) { return new Error('no user') } else if(r) { if(r.password != credentials.password) { return new

GraphQL-Java support for complex filters

Does anyone know whether the Java GraphQL implementation (graphql-java) supports complex filters. If I have understood this post correctly: The reference implementation includes filter argument is a built in argument which supports complex filters with nested conditions. However these examples do not work with the graphql-java examples. This is the simple example I am playing with using

Graphql How to wrap a remote schema in another query field?

Apollo graphql-tools now have Schema Stitching, which is great. I want to merge multiple endpoints to generate a schema similar to GraphQL Hub, like this: query { github: { ... } # GitHub Schema twitter: { ... } # Twitter Schema myOwnGraphqlSchema: { ... } } How is the best approach to do that? GitHub issue: Fork here for testing: Thank you.

Graphql: One-to-many delete mutation

I have a simple Graphql model User with a one-to-many relation to the model Post. I want to perform a mutation which would delete the User and all subsequent related posts. How should I structure the mutation?

Why do GraphQL Subscriptions use an AsyncIterator?

AsyncIterator requires pulling data using .next(). But with websockets I generally want to push data when events occur. Only thing I can think of is that by using pull-based they can rate-limit. So what is calling .next()? Is it a timer, or does it listen to a publish message, queue that, then call .next() until it consumes all the queue? Is this suitable for real-time data, like GPS positions on a map? Looked here and still could not figure it out:

Graphql Gatsby Source Contentful with Variable in Query

I'm creating some landing pages on my Gatsby site and want to list nodes from specific content types. For instance, I have: allContentfulSongs allContentfulBlogs In my landing page template, how can I dynamically query songs or blogs? I tried: all${landingPage} { edges { node { id } } } but I'm getting a syntax error. Is there a way to do this in Gatsby or should I just use an @include(if: $landingPage) for each contentType in my query?

Graphql Send POST request to apollo server with "operationName" and "variables"

I follow this doc and try to send a POST request to apollo server. test code: it('should get author correctly', () => { const body = { query: ` query { getAuthor($id: Int!) { name } } `, // operationName: 'query author', variables: { id: 1 } }; return => { expect(

Assemble graphql queries in one query without re-write the resolver or the definition

I have 3 graphql queries that calls 3 different services : { individualQ{ name } addressQ{ address } contactQ{ phone } } Each one of these 3 queries have its own resolver: individualQ (root , args) { const individual_options = getOption(cfg.INDIVIDUAL_ENDPOINT); return axios(individual_options).then(res =>; } , addressQ (root , args) { const address_options = getOption(cfg.ADDRESS_ENDPOINT); return axios(address_options).then(res => r

How do I specify a graphql type that takes multiple types?

I want to create a graphql type that can return either an Array of Integers or String. I've already tried using union in the form union CustomVal = [Int] | String, but this returns an error. The schema declaration is: union CustomValues = [Int] | String type Data { name: String slug: String selected: Boolean values: CustomValues } The error is: node_modules/graphql/error/syntaxError.js:24 return new _GraphQLError.GraphQLError('Syntax Error: ' + description, undefined, sour

GraphQL: Access type properties within @auth header

Say I have a GraphQL schema similar to: type Posts @model @auth(rules: [ {allow: groups, groups: ["Employees"], mutations: [create, update, delete, get, list]} ]) { id: ID! name: String groups: [String]! } And I want to allow only users who are listed in the Post's groups attribute to have those properties. I'd like to do something like: @auth(rules: [ {allow: groups, groups: [Device.groups], mutations: [create, update, delete, get, list]} ] Any ideas wher

How can I alias specific GraphQL requests in Cypress?

In Cypress, it is well-documented that you can alias specific network requests, which you can then "wait" on. This is especially helpful if you want to do something in Cypress after a specific network request has fired and finished. Example below from Cypress documentation: cy.server() cy.route('POST', '**/users').as('postUser') // ALIASING OCCURS HERE cy.visit('/users') cy.get('#first-name').type('Julius{enter}') cy.wait('@postUser') However, since I'm using GraphQL in my app, aliasing no l

Graphql Are mutation methods required to be on the top level?

All docs and tutorials usually show simple examples of mutations that look like this: extend type Mutation { edit(postId: String): String } But this way the edit method has to be unique across all entities, which to me seems like not a very robust way to write things. I would like to describe mutation similar to how we describe Queries, something like this: type PostMutation { edit(postId: String): String } extend type Mutation { post: PostMutation } This seems to be a valid schema

GraphQL filtering parent data in child resolver

I'm trying to figure out how to implement bottom up filtering in a parent-child relationship using GraphQL. Consider the following basic type hierarchy modelling a parking lot and available parking spots: type ParkingLot { id: Int! spots: [ParkingSpot] } type ParkingSpot { id: Int!, occupied: Boolean! } I want to implement my resolvers in a way that enables me to retrieve all parking lots which have at least one free parking spots. query AllParkingLotsWithStatus($status : Boolean

GraphQL products query Access Denied

I'm a little stuck with one GraphQL query. { collectionByHandle(handle:"price") { products(first: 16, sortKey:PRICE, query:"title:Bracelet"){ edges { cursor node { title } } } } } The error comes from the query parameter which is not supported on Custom collection, but it is on a Smart one. query: String This field is only used when the collection is smart. If the collection is custom it returns an error. Supported filter para

Graphql How to make resolvers run async

I am setting up java based graphQl App and find graphql-java-tools really convenient the problem though while itis pretty straight forward With graphql-java to make field resolvers Async I couldn't Find a way to do it using graphql-java-tools I tried @Bean public ExecutionStrategy executionStrategy() { return new AsyncExecutionStrategy(); } Here resolvers I use in order to test @Component public class VideoResolver implements GraphQLResolver<Video> { public

Graphql Apollo Server Slow Performance when resolving large data

When resolving large data I notice a very slow performance, from the moment of returning the result from my resolver to the client. I assume apollo-server iterates over my result and checks the types... either way, the operation takes too long. In my product I have to return large amount of data all at once, since its being used, all at once, to draw a chart in the UI. There is no pagination option for me where I can slice the data. I suspect the slowness coming from apollo-server and not my

How to abstract a graphQL query out of the component?

I have a NextJS project with a bare-bones <PostList /> component where I retrieve some test data from a GraphQL server using the react-apollo module: import { gql, graphql } from "react-apollo"; import withData from "../../apollo/withData"; const GET_POSTS = gql` { posts { _id title } } `; const PostList = ({data: {loading, posts}}) => { if(loading) { return (<div>Loading...</div>); } else { return ( <ul> {

Change backend service based on GraphQL Param

I have a GraphQL Schema as such: BigParent (parentParam: Boolean) { id name Parent { id name Child (childParam: Boolean) { id name } } } How can I write resolvers such that I call different backend APIs based on whether the parentParam is true or the childParam is true? The first option is straight-forward. The second one needs to kind of reconstruct the Graph based on the values returned by the service data returned at the level of Child. I'm not consider

Return any data from a query using GraphQL, Graphene and Python

I am receiving the following error: { "errors": [ { "message": "Unknown argument \"project_id\" on field" + \"get_project_detail_summary\" of type \"Query\".", "locations": [ { "line": 2, "column": 30 } ] } ] } With the following query: query GetProjectDetailSummary($project_id: Int) { get_project_detail_summary(project_id: $project_id) { comments { ... on ManagerCommentNode { id te

Graphql Input Object type `TypeName` must define one or more fields

I am experimenting with NestJS and TypeGraphQL. And I have an example model of a cat. import { Document } from 'mongoose'; import { ObjectType, InputType, Field, ID } from 'type-graphql'; export interface Cat extends Document { readonly name: string; readonly age?: number; } class CatBase { @Field() name: string; @Field({ nullable: true }) age?: number; } @ObjectType() export class CatObjectType extends CatBase implements Cat { @Field(type => ID) id: string; } @InputType

Creating a custom module in node for GraphQL?

I'm currently following this tutorial in an attempt to learn GraphQL with React but I'm getting the following error when trying to run npm start: Error: Cannot find module 'notarealdb' Require stack: - /Users/user/Workspace/intro-to-graphql/db.js - /Users/user/Workspace/intro-to-graphql/server.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15) at Function.Module._load (internal/modules/cjs/loader.js:864:27) at Module.require (internal/modules/cjs/loader.j

Nest.js GraphQL Field Resolver

my question is more about how to realize this. I didn't find answer inside docs so ask you); For example: I have 2 entity User and Blog; User has Blog as one to many relation; My query for User looks like: query { me { firstName lastName blogs { title description } } } In Nest.js code I have Resolver: @Resolver(() => UserEntity) class UserResolver { @Query(() => User) me() { ... } @ResolveField((

How to pass nested variables to the GraphQL query in Apollo?

Trying to pass nested variables to the GraphQL query but my server gets only top-level variables (shopId), everything else is null. I tried: #1 const CALCULATE_PACKAGE_PRICE = gql` query CalculatePackagePrice( $shopId: String! $address1: String $zip: String $city: String $countryCode: String ) { calculatePackagePrice( where: { shopId: $shopId destination: { address1: $address1 zip: $zip city: $city coun

graphql query to json query in graphiql

i have a query similar to this i fire in graphiql. this works perfectly and gives me a response query{ myAccounts(acctKey: "7777888888999") { ppCode acctDate acctLastUpdatedDate zoneId } } Now for some reason i need to pass the request as a json query instead of graphql query. I came across a solution similar to this graphql query to json query but couldn't quite get how to approach it. Is there any other way to achieve this,

Graphql How can I populate a search index using SitePage query?

I'm trying to implement search in my gastby blog. I've seen many tutorials and plugins but they all use Markdown, my blog is built with strapi and the pages are created dynamically. I realised the node allSitePage could give all the information I needed for the search index, I tried to use it in the flexsearch plugin like this in gatsby-config.js : { resolve: "gatsby-plugin-flexsearch", options: { languages: ["en"], type: "allSitePage",

How to prevent access to certain fields in Amplify graphql public API

I have a graphql model in Amplify as follows: type Blog @model @auth(rules: [ { allow: owner }, { allow: groups, groups: ["admins"] }, { allow: public, provider: apiKey, operations: [read] } ]){ id: ID! title: String! content: String! author: String } I would like all field to have read access via an API key except the 'author' field.It should only be readable by owner and the 'Admin' group. I have tried all sorts of combinations of top level and field

How can I configure Laravel Lighthouse to provide server-side rendering for GraphQL?

I'm using Apollo client for my React front-end to be able to use GraphQL hosted by Laravel Lighthouse. Normal uses cases work, but I'm now finding myself facing certain cases where I'd like to pre-fetch a GraphQL result on the initial page request instead of having the browser load the page and then send a separate ajax query. I see that Apollo client supports both "Store rehydration" and "Server-side rendering", but I haven't found any documentation within Lighthouse about h

Graphql average aggregate on nested data

What I would like to get is the average ScoreOverall of all the products within the List. I've tried adding some relationships but I can't get an aggregate "endpoint" on a nested level. The data model: List |--ListProducts (linking table, one list to many products) |--ProductScore (joined view) |--ScoreWeighted (value I want the average across all products in this List) Any clues on what the best approach for this would be?

How to remove unwanted node from a parsed graphql?

For example If I have some code like this: import gql from 'graphql-tag' const getUserMeta = /* GraphQL */ ` query GetUserMeta($owner: String!) { getUserMeta(owner: $owner) { familyName givenName workAddress facebookUrl owner createdAt updatedAt careers { items { id company companyUrl showCompany owner createdAt updatedAt } nextToken } }

Can I make variables optional in a GraphQL query?

I have a query that includes a variable $filter which is a string. This variable is only relevant if the user has said they want to filter the results. If user doesn't filter, I want all results back that meet the criteria. Is there a way to omit the filter variable in this query? I've tried passing null and I get an error. const NOTIFY_NEW_PUBLIC_FEELINGS = gql` subscription notifyNewPublicFeelings($page_id: uuid!, $filter: String!) { feelings( where: { is_public: { _eq: true }, pag

How to handle X-Hasura-Role with graphql codegen

Good morning, I have an Angular WebApp that uses GraphQL codegen with (apollo-angular plugin and all the typescript plugins). Everything works fine but I want to handle Hasura Roles and Hasura User ID. From Hasura Console everything is configured correctly and working. Only thing I am missing is how to handle this on the front end. I need to add X-Hasura-Role and X-Hasura-User-Id headers to every request sent to Hasura. Is there a way to do this with graphql-codegen? What is the right way to do

Graphql How can I filter data fetched from Contentful using a value also fetched from Contentful in Gatsby?

I am trying to fetch data from Contentful with a filter whose eq operator is also fetched from Contentful. In my current scenario, as shown in the code below, I am trying to filter the content fetched from allContentfulPost with the value fetched from label in contentfulCategory. Any ideas how I can do so? I tried using $label in the allContentfulPost filter eq operator, but that didn't work. export const pageQuery = graphql` query CategoryBySlug($slug: String!) { contentfulCategory (slu

Graphql Hasura - Permission migrations not applied

Until now, I used the hasura console to update my database schema (new column, table and manage permissions). Every time a change is made, a new migration is created. Today I added two columns and updated the permissions (select/insert/update). For some reason, I deleted and recreated my database. Every migrations worked fine but not the permissions. I have my new columns in my tables but the permissions are not persisted and I can't understand why... The last time I updated permissions, the met

Graphql How to add Access Rules to DynamoDB/AppSync?

I am using Amplify, AppSync, GraphQL, and DynamoDB in a chat-project. My aim is to build a chat-app similar to facebook-messenger. Is there a way to create access rules to certain DynamoDB documents (similar to Firestore Rules in Firebase)?. In other words, is is possible to only show certain documents to certain users in a safe and secure way?

Apollo/GraphQL not able to get referenced entities when asking for the ID

The stack: VueJS/Vuetify Apollo client Spring boot, MongoDB and GraphQL server The issue I'm facing is, when I execute my GraphQL query using Apollo and there is a collection of referenced entities, grabbing all the fields except the id works fine, but as soon as I add id { entityId organisationId } to also get the id fields, it returns a collection of all the same entity. Let's say there is three users: John, Jane and Jen; specifically in this order. When I execute the query, it will r

How do i create a graphql schema for a self referencing data hierarchy?

This doesnt work because the type refers to its self in the routes field definition: var routeType = new GraphQLObjectType({ name: 'MessageRoute', fields: { name: { type: GraphQLString }, routes: { type: new GraphQLList(routeType), resolve: (route) => { return route.routes; } } } }); so how do I do it?

What are the "GraphQL calls" in the `rangeBehaviors` attribute of the `RANGE_ADD` mutator config?

The docs describe rangeBehaviors as: A map of GraphQL calls to the behavior we want Relay to exhibit when adding the new edge to connections under the influence of those calls. Behaviors can be one of 'append', 'prepend', or 'remove'. The example in the docs is: rangeBehaviors: { // When the ships connection is not under the influence // of any call, append the ship to the end of the connection '': 'append', // Prepend the ship, wherever the connection is sorted by age 'orderby(

How to use the names in a GraphQLEnumType as the defaultValue of a GraphQL query argument?

When defining a query in a schema, how do I refer to a value of an GraphQLEnumType declared previously, to use it as the default value of an argument? Let's say I've defined following ObservationPeriod GraphQLEnumType: observationPeriodEnum = new GraphQLEnumType { name: "ObservationPeriod" description: "One of the performance metrics observation periods" values: Daily: value: '1D' description: "Daily" […] } and use it as the type of query argument period: queryRoot

How can I signal an error in a graphql apollo-server mutation resolver?

The documentation tells us that a resolver has this form: fieldName: (obj, args, context, info) => result And that result is null or undefined if "the object could not be found". What about other errors - for example, if the access is not authorised? It appears that you can't directly "return" an error, because the result has to match the schema. I've tried throwing an exception in the resolver, and this almost does the right thing: the client gets an ApolloError with the exception mess

Graphql apollo-client Network error if field is null

This particular code has been now running without issues for months, this morning, without any relevant change I can pinpoint in our setup or our code I started receiving ERROR Error: Uncaught (in promise): Error: Network error: Cannot convert undefined or null to object Error: Network error: Cannot convert undefined or null to object at new ApolloError (ApolloError.js:43) at eval (QueryManager.js:324) at eval (QueryManager.js:755) at Array.forEach (<anonymous>) at ev

Graphql Prismy deploy command throws Invalid Version error

I'm just following the basic get started guide ( When I want to run the deploy command (prisma deploy) I keep getting this error: ! Invalid Version: 1.1 Get in touch if you need help: To get more detailed output, run $ export DEBUG="*" There seem to be no results related to this on Google or Prisma's forums.

Graphql User specific publish (subscriptions)

Here's a small issue I faced and couldn't find much info in the documentation. I am trying to create private chat messages. We have the following code to subscribe a user to a topic: export const resolvers = { Subscription: { somethingChanged: { subscribe: () => pubsub.asyncIterator('chat_messages'), }, }, } and to publish pubsub.publish('chat_messages', { somethingChanged: { sender_id: 1, receiver_id: 2, message: 'test' }}); I have used onConnect to verify that the us

Graphql AppSync subscription authorization problem

Hi i am new in aws AppSync and GraphQl. I have a problem with subscription. I want to get notifiend in real time when new post is posted Here is my graphql schema `` type Mutation { addPost( id: ID!, author: String!, title: String, contennt: String, url: String ): Post! updatePost( id: ID!, author: String!, title: String, content: String, ups: Int! ): Post! deletePost(id: ID): Post! } type Pos

How to disable GraphQL Playground in Serverless production?

Is there a way to disable the playground function in production? In my serverless.yml functions: graphql: # this is formatted as <FILENAME>.<HANDLER> handler: handler.graphqlHandler events: - http: path: api/v1 method: post playground: handler: handler.playgroundHandler events: - http: path: playground method: get In my handler.js import { ApolloServer, gql } from "apollo-server-lambda"; import lambdaPlayground fr

Graphql Apollo Client: Send different headers relative to authentication/authorization

I will often have an expired authorization token in my app. I do not, however, want this error to block requests that do not require authorization. What is the work around? I'd like to customize my headers for requests to simply view a page (which doesn't require token, so send with an empty header) and for requests to edit data (add token and allow error to block request). An invalid token, with headers set like below for every request, is now blocking the simple fetching of open data: con

Graphql Apollo useQuery() - "refetch" is ignored if the response is the same

I am trying to use Apollo-client to pull my users info and stuck with this problem: I have this Container component responsible for pulling the user's data (not authentication) once it is rendered. User may be logged in or not, the query returns either viewer = null or viewer = {...usersProps}. Container makes the request const { data, refetch } = useQuery<Viewer>(VIEWER);, successfully receives the response and saves it in the data property that I use to read .viewer from and set it as

Graphql Apollo Subscription with Gatsby Setup

below is my setup of Gatsby SSR with Apollo for those looking for a solution on how to set them up. Hope it helps those looking online for a solution on how to set up Gatsby with Apollo Credits: [] I am not sure at the moment if my onError variable is placed correctly. I will look it up Nonetheless, subscription with gatsby client-side routes is working fine with this setup

NestJS GraphQLFederationModule code first schema

I am trying to split my application into microservices as i need to scale some of them. What i've tried to do so far, is just simply changing the module structure of my NestJS application by changing the GraphQL module type used to this piece of code. GraphQLFederationModule.forRoot({ autoSchemaFile: join(process.cwd(), './src/graphql/schema.gql'), typePaths: [ join(process.cwd(), './src/graphql/*.graphql'), join(process.cwd(), './src/graphql/*.gql') ], debug: pro

  1    2   3   4   5   6  ... 下一页 最后一页 共 14 页