graphql-js

Passing data through a GRAPHQL Subscription gives null on only one of the arguments

泄露秘密 提交于 2021-02-17 05:23:34
问题 I have the following GRAPHQL subscription: Schema.graphql type Subscription { booking: SubscriptionData } type SubscriptionData { booking: Booking! action: String } And this is the resolver subsrciption file Resolver/Subscription.js const Subscription = { booking: { subscribe(parent, args, { pubsub }, info) { return pubsub.asyncIterator("booking"); } } }; export default Subscription; Then I have the following code on the Mutation in question pubsub.publish("booking", { booking: { booking },

How to store the data in React state after Querying it from GraphQL?

ⅰ亾dé卋堺 提交于 2021-02-11 15:51:19
问题 Following is my Query: import React from 'react'; import getProducts from '../queries/getProduct'; import { Query } from "react-apollo"; export const Product = () => { const proId = { "productId": "95eb601f2d13" } return ( <Query query={getProducts} variables={proId}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <div> {data.map(entry => entry)} </div> ); }} </Query> ); }; export default Product; I need to now store

How to store the data in React state after Querying it from GraphQL?

坚强是说给别人听的谎言 提交于 2021-02-11 15:49:08
问题 Following is my Query: import React from 'react'; import getProducts from '../queries/getProduct'; import { Query } from "react-apollo"; export const Product = () => { const proId = { "productId": "95eb601f2d13" } return ( <Query query={getProducts} variables={proId}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <div> {data.map(entry => entry)} </div> ); }} </Query> ); }; export default Product; I need to now store

How to store the data in React state after Querying it from GraphQL?

牧云@^-^@ 提交于 2021-02-11 15:48:50
问题 Following is my Query: import React from 'react'; import getProducts from '../queries/getProduct'; import { Query } from "react-apollo"; export const Product = () => { const proId = { "productId": "95eb601f2d13" } return ( <Query query={getProducts} variables={proId}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <div> {data.map(entry => entry)} </div> ); }} </Query> ); }; export default Product; I need to now store

graphql, how to design input type when there are “add” and “update” mutation?

喜夏-厌秋 提交于 2021-02-07 05:18:37
问题 Here are my requirements: "add" mutation, every field(or called scalar) of BookInput input type should have additional type modifiers "!" to validate the non-null value. Which means when I add a book, the argument must have title and author field, like {title: "angular", author: "novaline"} "update" mutation, I want to update a part of fields of the book, don't want to update whole book(MongoDB document, And, I don't want front-end to pass graphql server a whole big book mutation argument for

How to implement GraphQL Scalar for MongoDB sort property found in collection.find() function of MongoDB's?

强颜欢笑 提交于 2021-01-29 13:40:13
问题 I'm trying to create an argument type using type-graphql to accept arguments through the GraphQL query. The sort I'm talking about is a property of the options found on MongoDB's native NodeJS driver documentation. @ArgsType() export class FindAllArgs implements FindOneOptions { @Field(type => Int, { defaultValue: 0, description: 'Sets the limit of documents returned in the query.' }) @Min(0) limit?: number; // This is where the custom sort would go about. @Field(type => SortScalar) sort?:

Apollo client doesn't display an error message

梦想与她 提交于 2021-01-27 17:42:30
问题 I have configured and set up a fully functional express-nextjs-graphql-apollo app that can login/logout a user, and perfectly do CRUD. The last and very important step is to display error messages on client-side. So far, I'm only getting this red error in a console: POST http://localhost:3000/graphql 500 (Internal Server Error) For example, a login form validation. When no input is provided, it's supposed to get an invalid input error message, or E-Mail is invalid if email format is incorrect

Cache data may be lost when replacing the my field of a Query object

谁说我不能喝 提交于 2021-01-04 08:00:06
问题 this my code const NewVerificationCode = () => { const { loading, error, data = {}, refetch } = useQuery(CONFIRMATION_CODE, { skip: true, onError: (err) => {}, }); console.log(loading, error, data); if (loading || error) { return <ErrorLoadingHandler {...{ loading, error }} />; } return ( <form onSubmit={(e) => { refetch(); e.preventDefault(); }} > <div> <button type="submit" className="signUpbutton"> {"Send the message again"} </button> </div> </form> ); }; const CONFIRMATION_CODE = gql`

Cache data may be lost when replacing the my field of a Query object

心不动则不痛 提交于 2021-01-04 07:59:12
问题 this my code const NewVerificationCode = () => { const { loading, error, data = {}, refetch } = useQuery(CONFIRMATION_CODE, { skip: true, onError: (err) => {}, }); console.log(loading, error, data); if (loading || error) { return <ErrorLoadingHandler {...{ loading, error }} />; } return ( <form onSubmit={(e) => { refetch(); e.preventDefault(); }} > <div> <button type="submit" className="signUpbutton"> {"Send the message again"} </button> </div> </form> ); }; const CONFIRMATION_CODE = gql`

When to use enter/leave with `visit` function of `graphql`

回眸只為那壹抹淺笑 提交于 2020-12-15 05:25:26
问题 I'm trying to remove some nodes from a ast of graphql using the visit function. Just as the doc says, there are two event I can hook into enter leave I don't know when to use enter and when to use leave, what's the deference between them? How can I tell which one to use? 回答1: The main difference is that enter() allows you to skip the subtree if you don't care about it. There is a section on this page https://graphql.org/graphql-js/language/#visitor that describes the return values permitted