relayjs

Cannot set property 'clientMutationId' of undefined

一笑奈何 提交于 2019-12-23 10:07:12
问题 I am getting following error. when trying to run a mutation via graphiql. Please help me resolve this issue or point to a link where I can find react relay mutations example. mutation { createUser(input: {username: "Hamza Khan", clientMutationId: ""}) { user { id username } } } { "data": { "createUser": null }, "errors": [ { "message": "Cannot set property 'clientMutationId' of undefined", "locations": [ { "line": 17, "column": 2 } ] } ] } Here is the mutation definition import {

How to get data from the local graph?

大憨熊 提交于 2019-12-23 04:57:19
问题 I've got the component which displays the hierarchical data. It's a recursive data structure - a hierarchical classifier. Each category in the classifier consists of child categories and so on. Here's the playground for it: Relay playground I've got a component showing this classifier in a third party html form. It is used to pick a category. At some point in time a user will pick a category from this recursive classifier and I will have to get the full path of data that led to the current

Integration testing of Relay containers with Jest against a working GraphQL backend not working

懵懂的女人 提交于 2019-12-23 01:36:24
问题 I'd like to implement the integration testing of my Relay containers against a running GraphQL backend server. I'm going to use Jest for this. I'd like to say that unit testing of React components works well as expected with my Jest setup. Here's what I have in the package.json for the Jest: "jest": { "moduleFileExtensions": [ "js", "jsx" ], "moduleDirectories": [ "node_modules", "src" ], "moduleNameMapper": { "^.+\\.(css|less)$": "<rootDir>/src/styleMock.js", "^.+\\.(gif|ttf|eot|svg|png)$":

Which relay objects must implement `Node`?

帅比萌擦擦* 提交于 2019-12-21 17:25:44
问题 https://facebook.github.io/relay/graphql/objectidentification.htm is very clear around what Node is and how it behaves, but it doesn't specify which objects must implement it, or what the consequences are if your object doesn't implement it. Is there a set of features that don't work? Are such objects completely ignored? Not all objects in the existing spec (e.g. pageInfo ) implement it, so it's clearly not universally required, but pageInfo is somewhat of a special case. 回答1: Another way of

Authorization in GraphQL servers

情到浓时终转凉″ 提交于 2019-12-21 04:32:08
问题 How to handle Authorization in GraphQL servers? Shall I pass the JWT token in the Authentication header of every requests and check for the authorized user after resolve() and check for the role of user on every query and mutation 回答1: Introduction First of all, a common approach for authentication as you state is using a signed JWT that contains the id of the user making the request. Now let's have a look at the different parameters we can use when considering the authorization of a given

relayjs: authentication using relay, which mutation to use?

回眸只為那壹抹淺笑 提交于 2019-12-21 03:37:21
问题 I am currently handling authentication outside of relay with custom header set in DefaultNetworkLayer. Is it preferred way and Is there a way to do it in relay? I was stuck when trying to implement sign up functionality in relay: in relay there are following configs: FIELDS_CHANGE, NODE_DELETE, RANGE_ADD, RANGE_DELETE. So RANGE_ADD is the only one applicable here, however I need a parent and connection for that, which I do not have for a newly created user.... 回答1: I had this issue on my

Authentication and Access Control with Relay

杀马特。学长 韩版系。学妹 提交于 2019-12-20 09:36:31
问题 The official line from Facebook is that Relay is "intentionally agnostic about authentication mechanisms." In all the examples in the Relay repository, authentication and access control are a separate concern. In practice, I have not found a simple way to implement this separation. The examples provided in the Relay repository all have root schemas with a viewer field that assumes there is one user. And that user has access to everything. However, in reality, an application has has many users

Pass variables to fragment container in relay modern

℡╲_俬逩灬. 提交于 2019-12-18 13:21:15
问题 I'm using Relay Modern (compat). I have a fragment that contains a field that has one argument, but I can't find a way of passing the variable value from the parent component: // MyFragmentComponent.jsx class MyFragmentComponent extends Component {...} const fragments = { employee: graphql` fragment MyFragmentComponent_employee on Employee { hoursWorked(includeOvertime: $includeOvertime) dob fullName id } `, } export default Relay.createFragmentContainer(MyFragmentComponent, fragments) It

How to get the ID of a new object from a mutation?

妖精的绣舞 提交于 2019-12-18 12:27:06
问题 I have a createObject mutation that returns the ID of the new object. After it returns I want to redirect to a detail page about the new object. How can I get response fields from a mutation in the containing component using react/relay? E.g. my createObject page contains the mutation with code like: var onFailure = (transaction) => { }; var onSuccess = () => { redirectTo('/thing/${newthing.id}'); // how can I get this ID? }; // To perform a mutation, pass an instance of one to `Relay.Store

How would you do file uploads in a React-Relay app?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 12:15:46
问题 A file upload seems like a mutation. It's often accompanied by other data. But it's a big binary blob, so I'm not sure how GraphQL can deal with it. How would you integrate file uploads into an app built with Relay? 回答1: First you need to write the Relay update in your frontend component. Like this: onDrop: function(files) { files.forEach((file)=> { Relay.Store.commitUpdate( new AddImageMutation({ file, images: this.props.User, }), {onSuccess, onFailure} ); }); }, And then follow by