I'm trying to add a new project with a connected user assigned to a project but I continue to receive an error 'GraphQL error: field "user_id" not found in type: 'projects_insert_input''
Each project has a user_id column mandatory (I can add projects inside the graphiql editor on hasura, but not on my client)
mutation
const ADD_PROJECT = gql`
mutation ($project: String!, $isPublic: Boolean!, $user: String!) {
insert_projects(objects:
{
title: $project,
is_public: $isPublic,
user_id: $user
}
) {
affected_rows
returning {
id
title
created_at
is_completed
}
}
}
`;
const ProjectInput = ({ isPublic = false }) => {
let input;
const [projectInput, setProjectInput] = useState('');
const [addProject] = useMutation(ADD_PROJECT);
return (
<form className="formInput">
<input
className="input"
placeholder="What needs to be done?"
value={projectInput}
onChange={e => (setProjectInput(e.target.value))}
ref={n => (input = n)}
/>
<button onClick={(e) => {
e.preventDefault();
addProject({
variables:
{
project: projectInput,
isPublic,
user: "auth0|5e6d66e02ae6a80c8bc42eb4"
// description: projectDescInput
}
});
}}>Click me</button>
<i className="inputMarker fa fa-angle-right" />
</form>
);
};
insert_projects
as suchinsert_projects(objects: [{...}]) { ... }
. Relevant documentation: hasura.io/docs/1.0/graphql/manual/mutations/… – Perak