Comments (12)
Hi @Richard87,
Thanks for the issue!
Have you tried to pass variables: { ... }
to the config.mutation
prop of <ApplicationForm>
?
from react-apollo-form.
Hi, thanks for answering so fast ;)
I tried this, but it had no effect, so I'm not sure how it's supposed to look?
<ApplicationForm
title="Create site form"
liveValidated={true}
noHtml5Validate={true}
config={{
mutation: {
name: 'createSite',
document: createSiteMutationDocument,
variables: {clientMutationId: 1}
},
saveData: data => {
console.log('save !', data);
}
}}
/>
from react-apollo-form.
Looks like there is a bug in the JSON Schema based on your GraphQL API Schema.
Could you send me your apollo-form-json-schema.json
so I could take a look?
(send me privately if you want to [email protected] (even just the concerned mutation part))
Cheers,
from react-apollo-form.
As a workaround, until a fix is found and delivred, you can try to Build a form without a mutation 😉
from react-apollo-form.
Hi!
Here is my apollo-form-json-schema.json
:)
from react-apollo-form.
from react-apollo-form.
Ps, The schema is produced by API-Platform (https://github.com/api-platform/api-platform)
from react-apollo-form.
Hi! I Updated everything...
apollo-form-sjon-schema.json
: https://pastebin.com/kSaQj3dD
schema.json
: https://pastebin.com/LRJTf2aM
Richard
from react-apollo-form.
My current code:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import registerServiceWorker from './registerServiceWorker';
import {ApplicationForm} from "./ApplicationForm";
import gql from 'graphql-tag'
const createSiteMutationDocument = gql`
mutation createSite($clientMutationId: String!, $domain: String!) {
createSite(input: {clientMutationId: $clientMutationId,domain: $domain}) {
id
}
}
`;
ReactDOM.render(
<ApplicationForm
title="Todo Form"
liveValidate={true}
config={{
mutation: {
name: 'createSite',
document: createSiteMutationDocument
}
}}
/>
, document.getElementById('root'));
registerServiceWorker();
My ApplicationForm
:
import * as React from 'react';
import { configure } from 'react-apollo-form';
import { client } from './apollo'; // a file thats export a configured Apollo Client
import jsonSchema from './forms/apollo-form-json-schema.json';
export const ApplicationForm = configure({
client: client,
jsonSchema
});
Request:
{
"operationName": "createSite",
"variables": {
"input": {
"domain": "testtest",
"openingHours": [],
"clientMutationId": "4"
}
},
"query": "mutation createSite($clientMutationId: String!, $domain: String!) {\n createSite(input: {clientMutationId: $clientMutationId, domain: $domain}) {\n id\n __typename\n }\n}\n"
}
Response:
{
"errors": [
{
"message": "Variable \u0022$clientMutationId\u0022 of required type \u0022String!\u0022 was not provided.",
"category": "graphql",
"locations": [
{
"line": 1,
"column": 21
}
]
},
{
"message": "Variable \u0022$domain\u0022 of required type \u0022String!\u0022 was not provided.",
"category": "graphql",
"locations": [
{
"line": 1,
"column": 49
}
]
}
]
}
Repository: https://github.com/Richard87/test-apollo-form
from react-apollo-form.
Okay, if I use this qql
, it works (just custom input variables etc fails):
mutation createSite($input: createSiteInput!) {
createSite(input: $input) {
id
}
}
from react-apollo-form.
Hi @Richard87,
Yes I had the same conclusion after comparing you GQL schema and generated JSON Schema.
Indeed, the mutation document passed to <ApplicationForm>
should use identical arguments as those accepted by the API corresponding mutation.
This point is not clear and the documentation and of course you feature proposal - generate this query document for you - would make this easier!
Sorry for the lack of documentation on this subject and thanks for pointing it out! 🙇
from react-apollo-form.
No problem. But I think the posibility to generate my own mutation with the specific fields I want would be good to have? Then it would be easier to generate the "layout" i want in the DOM...
For example in the example over, I don't want opening hours, but that might be solved by "ignore fields" :)
Also, I appreciate the quick feedback, I really love the concept of this library and hopefully one day I could contribute more than just opening issues :D
from react-apollo-form.
Related Issues (20)
- Question: Why is mutation document needed when you have all the details in schema.json? HOT 1
- cli not found @ 0.1.6 HOT 5
- Get result of the mutation HOT 1
- Doesnt handle arrays in mutation HOT 3
- Question: Integration with react-jsonschema-form-conditionals HOT 2
- no such file or directory 'react-apollo-form\dist\lib\cli.js' HOT 7
- theming question
- Dependency deprecation warning: apollo-codegen (npm)
- What about handling active, dirty, touched, valid, etc? HOT 2
- IMPORTANT: react-apollo-form full rewrite on-going HOT 9
- Maintenance state HOT 1
- ivandoric
- Issue with theming HOT 1
- Form data disappears. HOT 1
- graphql-2-json-schema 0.1.0-1 doesn't handle enums properly HOT 1
- No way to set FormContext
- Cannot read property 'name' of null HOT 1
- [Question]: Support for react-i18n HOT 1
- Dependency Dashboard
- How to create custom array fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-apollo-form.