Dataprovider resulting in String instead of Int

I am using the Hasura dataprovider, and i've passed the following const gqlDataProvider = dataProvider(client, {idType: "Int"}); Expecting it to give an Int, but it keeps giving me a string, when my schema needs an Int. Coming from this query export const COMPANY_TITLE_QUERY = gql query CompanyTitle($where: ID!) { companies(where: $id) { id name createdAt avatarUrl salesOwner { id name avatarUrl } } } ; Which is from the onFinish function. Why isnt it passing an int? And the where variable? This is the payload {,…} operationName : "CompanyTitle" query : "query CompanyTitle($where: ID!) {\n companies(where: $id) {\n id\n name\n createdAt\n avatarUrl\n salesOwner {\n id\n name\n avatarUrl\n }\n }\n}\n" variables : {id: "21"} Response { "errors": [ { "message": "expecting a value for non-nullable variable: "where"", "extensions": { "path": "$", "code": "validation-failed" } } ] }
K
kapa.ai55d ago
Hi @Konungariket Sverige. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided from the extracts, it seems like you're encountering an issue with the Hasura data provider in refine, specifically with the handling of ID types. You've configured the data provider to use Int as the ID type, but you're still getting a string, and there's also an issue with the where variable in your query. Firstly, it's important to note that when you initialize the data provider with {idType: "Int"}, this configuration is supposed to instruct the data provider to treat IDs as integers. However, your query seems to have a mismatch in variable usage which might be causing the issue:
query CompanyTitle($where: ID!) {
companies(where: $id) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
query CompanyTitle($where: ID!) {
companies(where: $id) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
In the query, you've defined a variable $where of type ID!, but in the companies query, you're using $id which is not defined anywhere in your query. This mismatch is likely causing the GraphQL server to not understand your query correctly, leading to the error message about expecting a value for the non-nullable variable where. To address this issue, you should correct the variable in your query to match the defined variable name and ensure it's passed correctly in the variables object of your request. Here's a corrected version of your query:
query CompanyTitle($id: ID!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
query CompanyTitle($id: ID!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
And ensure your variables object matches this:
{
"id": "21"
}
{
"id": "21"
}
Regarding the issue of IDs being treated as strings instead of integers, it's worth noting that GraphQL itself treats all IDs as strings, even if they represent numeric values. This is part of the GraphQL specification to ensure ID uniqueness across different systems. However, if your database schema or GraphQL schema expects an integer, you need to ensure that the conversion or casting is handled appropriately in your resolver or in the way you construct your query. Unfortunately, based on the extracts provided, there's no direct solution mentioned for converting string IDs to integers within the context of the refine Hasura data provider. If this issue persists, consider reviewing the documentation or source code of the refine Hasura data provider for any additional configuration options or reaching out to the refine community for more specific guidance. For more detailed information or updates on the Hasura data provider within refine, you might want to check the official documentation or GitHub repository issues for any similar reported issues or updates: - Refine Hasura Data Provider Documentation (https://refine.dev/docs/examples/data-provider/hasura) - Refine GitHub Issues (https://github.com/refinedev/refine/issues) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai55d ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
R
rare-sapphire55d ago
@kapa.ai I've updated into this export const COMPANY_TITLE_QUERY = gql query CompanyTitle($id: Int_comparison_exp) { companies(where: {id: $id}) { id {errors: [{message: "expected an object for type 'Int_comparison_exp', but found a string",…}]} errors : [{message: "expected an object for type 'Int_comparison_exp', but found a string",…}] 0 : {message: "expected an object for type 'Int_comparison_exp', but found a string",…} extensions : {path: "$.selectionSet.companies.args.where.id", code: "validation-failed"} message : "expected an object for type 'Int_comparison_exp', but found a string" name createdAt avatarUrl salesOwner { id name avatarUrl } } } ; But i get this now
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the updated query and the error message you've received, it looks like the issue is related to how you're using the Int_comparison_exp in your GraphQL query. The error message indicates that the GraphQL server expected an object for the type Int_comparison_exp, but a string was provided instead. This suggests a mismatch between the expected input type for the id field in your where clause and the actual value you're providing. The Int_comparison_exp is typically used in Hasura for providing complex filters that allow for operations like less than, greater than, etc., on integer fields. When you specify $id: Int_comparison_exp as the type for your variable, you need to provide an object that matches this expected structure. Here's a corrected approach to using Int_comparison_exp in your query:
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
And when you're calling this query, you need to ensure that the $id variable is passed as an object that matches the Int_comparison_exp expectations. For example, if you're looking for a company with the ID equal to 21, your variables should look something like this:
{
"id": {
"_eq": 21
}
}
{
"id": {
"_eq": 21
}
}
This structure tells Hasura to look for companies where the id is equal to 21, matching the Int_comparison_exp input type's requirements. Remember, the exact structure of the Int_comparison_exp might vary based on your GraphQL schema and the configurations in your Hasura instance. If you're unsure about the structure or how to use it, consulting the Hasura documentation specific to your version or exploring the schema in the Hasura console can provide more insights. Unfortunately, without direct extracts related to handling Int_comparison_exp in the context of refine or Hasura from the provided information, this is the best guidance I can offer based on standard GraphQL and Hasura practices. If this doesn't resolve your issue, I recommend checking the Hasura documentation or seeking further assistance from the refine community or Hasura support channels. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai55d ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
R
rare-sapphire55d ago
@kapa.ai So how i make sure it's being sent like this in my query? { "id": { "_eq": 21 } }
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- To ensure your query sends the id in the format {"id": {"_eq": 21}}, you need to adjust both your GraphQL query and the way you pass variables to it. Since the extracts provided don't include specific examples of executing a GraphQL query with variables in the context of refine or a similar environment, I'll guide you based on general GraphQL practices. First, ensure your GraphQL query is correctly set up to accept an object for the id field, as shown in the previous response. Here's the query again for reference:
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
Next, when you're executing this query, you'll need to structure your variables to match the expected format. This step depends on how you're making the GraphQL request. If you're using a GraphQL client library (like Apollo Client, URQL, or even a simple fetch API call), you'll pass the variables along with your query. Here's an example of how you might do this with a generic GraphQL client or a fetch API call:
const variables = {
id: {
_eq: 21
}
};

// Assuming `graphqlClient` is your GraphQL client instance
// and it has a method `query` to execute GraphQL queries.
graphqlClient.query({
query: COMPANY_TITLE_QUERY,
variables: variables
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error);
});
const variables = {
id: {
_eq: 21
}
};

// Assuming `graphqlClient` is your GraphQL client instance
// and it has a method `query` to execute GraphQL queries.
graphqlClient.query({
query: COMPANY_TITLE_QUERY,
variables: variables
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error);
});
Or, if you're using a fetch API directly, it might look something like this:
fetch('YOUR_GRAPHQL_ENDPOINT', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}`,
variables: {
id: {
_eq: 21
}
}
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
fetch('YOUR_GRAPHQL_ENDPOINT', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}`,
variables: {
id: {
_eq: 21
}
}
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Remember to replace 'YOUR_GRAPHQL_ENDPOINT' with the actual endpoint of your GraphQL server. This approach ensures that your query is executed with the id variable structured as an object, matching the Int_comparison_exp type's requirements. Keep in mind that the exact implementation might vary based on the specifics of your GraphQL client or setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai55d ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
R
rare-sapphire55d ago
@kapa.ai This is part of the schema "Boolean expression to compare columns of type "Int". All fields are combined with logical 'AND'." input Int_comparison_exp {_eq: Int _gt: Int _gte: Int _in: [Int!] _is_null: Boolean _lt: Int _lte: Int _neq: Int _nin: [Int!] } And this is the query export const COMPANY_TITLE_QUERY = gql query CompanyTitle($id: Int_comparison_exp!) { companies(where: {id: $id}) { id name createdAt avatarUrl salesOwner { id name avatarUrl } } } ;
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the schema information you've provided and the query you're using, it looks like you're correctly set up to use the Int_comparison_exp for filtering in your Hasura GraphQL query. The Int_comparison_exp input type allows you to perform various comparisons on columns of type Int, using fields like _eq, _gt, _gte, etc., all combined with a logical 'AND'. Given the schema snippet:
"Boolean expression to compare columns of type \"Int\". All fields are combined with logical 'AND'."
input Int_comparison_exp {
_eq: Int
_gt: Int
_gte: Int
_in: [Int!]
_is_null: Boolean
_lt: Int
_lte: Int
_neq: Int
_nin: [Int!]
}
"Boolean expression to compare columns of type \"Int\". All fields are combined with logical 'AND'."
input Int_comparison_exp {
_eq: Int
_gt: Int
_gte: Int
_in: [Int!]
_is_null: Boolean
_lt: Int
_lte: Int
_neq: Int
_nin: [Int!]
}
And your query:
export const COMPANY_TITLE_QUERY = gql`
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
`;
export const COMPANY_TITLE_QUERY = gql`
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
`;
To use this query effectively, you need to pass a variable that matches the Int_comparison_exp structure when executing the query. For example, if you want to find companies with an id equal to 21, your variables object should look like this:
{
"id": {
"_eq": 21
}
}
{
"id": {
"_eq": 21
}
}
This tells Hasura to filter the companies where the id is equal to 21. Here's how you might execute this query with a GraphQL client, assuming you're using Apollo Client:
import { gql, useQuery } from '@apollo/client';

const COMPANY_TITLE_QUERY = gql`
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
`;
const { loading, error, data } = useQuery(COMPANY_TITLE_QUERY, {
variables: { id: { _eq: 21 } }
});

if (loading) return <p>Loading...</p>;
if (error) return <p>Error :(</p>;

return (
<div>
{/* Render your data here */}
</div>
);
import { gql, useQuery } from '@apollo/client';

const COMPANY_TITLE_QUERY = gql`
query CompanyTitle($id: Int_comparison_exp!) {
companies(where: {id: $id}) {
id
name
createdAt
avatarUrl
salesOwner {
id
name
avatarUrl
}
}
}
`;
const { loading, error, data } = useQuery(COMPANY_TITLE_QUERY, {
variables: { id: { _eq: 21 } }
});

if (loading) return <p>Loading...</p>;
if (error) return <p>Error :(</p>;

return (
<div>
{/* Render your data here */}
</div>
);
This example uses Apollo Client's useQuery hook to execute the COMPANY_TITLE_QUERY, passing the id variable as required. Adjust the implementation according to your setup and the GraphQL client you're using. Remember, the exact way you execute the query might vary depending on the GraphQL client and the environment (React, Vue, Angular, etc.) you're working in. The key is to ensure that the variables you pass to the query match the expected structure defined by your GraphQL schema. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai55d ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
R
rare-sapphire55d ago
@kapa.ai I am abit stuck with the onChange, onFinish and useform components Below is the code const TitleInput = ({ value, onChange, loading, }: { // value is set by <Form.Item /> value?: string; onChange?: (value: string) => void; loading?: boolean; }) => { return ( <Text className={styles.title} size="xl" strong editable={{ onChange, triggerType: ["text", "icon"], icon: <EditOutlined className={styles.titleEditIcon} />, }} > {loading ? ( <Skeleton.Input size="small" style={{ width: 200 }} active /> ) : ( value )} </Text> ); }; With the query: export const COMPANY_TITLE_FORM_MUTATION = gql mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) { update_companies(_set: $set, where: $where) { returning { id name avatarUrl user { id name avatarUrl } } } } ; And my payload looks like this operationName : "CompanyTitleForm" query : "mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {\n update_companies(_set: $set, where: $where) {\n returning {\n id\n name\n avatarUrl\n user {\n id\n name\n avatarUrl\n }\n }\n }\n}\n" variables : {id: "21", object: {salesOwnerId: 1}} id : "21" object : {salesOwnerId: 1} salesOwnerId : 1 Which seems right but gives this error {errors: [{message: "expecting a value for non-nullable variable: "set"",…}]} errors : [{message: "expecting a value for non-nullable variable: "set"",…}] 0 : {message: "expecting a value for non-nullable variable: "set"",…} extensions : {path: "$", code: "validation-failed"} message : "expecting a value for non-nullable variable: "set"" I am also using an Hasura provider for this, why is that?
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the information provided, it seems like you're encountering an issue with a GraphQL mutation when trying to update company information using Hasura. The error message you're receiving indicates that the mutation expects a value for a non-nullable variable named set, but it's not receiving one in the payload you're sending. The mutation you've shared is:
export const COMPANY_TITLE_FORM_MUTATION = gql`
mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {
update_companies(_set: $set, where: $where) {
returning {
id
name
avatarUrl
user {
id
name
avatarUrl
}
}
}
}
`;
export const COMPANY_TITLE_FORM_MUTATION = gql`
mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {
update_companies(_set: $set, where: $where) {
returning {
id
name
avatarUrl
user {
id
name
avatarUrl
}
}
}
}
`;
And the payload looks like this:
{
"operationName": "CompanyTitleForm",
"query": "mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {\n update_companies(_set: $set, where: $where) {\n returning {\n id\n name\n avatarUrl\n user {\n id\n name\n avatarUrl\n }\n }\n }\n}\n",
"variables": {
"id": "21",
"object": {
"salesOwnerId": 1
}
}
}
{
"operationName": "CompanyTitleForm",
"query": "mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {\n update_companies(_set: $set, where: $where) {\n returning {\n id\n name\n avatarUrl\n user {\n id\n name\n avatarUrl\n }\n }\n }\n}\n",
"variables": {
"id": "21",
"object": {
"salesOwnerId": 1
}
}
}
The error message you're receiving is:
{
"errors": [
{
"message": "expecting a value for non-nullable variable: \"set\"",
"extensions": {
"path": "$",
"code": "validation-failed"
}
}
]
}
{
"errors": [
{
"message": "expecting a value for non-nullable variable: \"set\"",
"extensions": {
"path": "$",
"code": "validation-failed"
}
}
]
}
The issue here seems to be with how the variables are structured in your payload. The mutation expects two variables: $set and $where. However, in your payload, you're providing an id and an object with salesOwnerId inside it. It looks like there's a mismatch between what your mutation expects and what you're providing. To resolve this issue, you need to adjust your payload to correctly map to the $set and $where variables expected by the mutation. Here's how you might structure your variables correctly:
{
"variables": {
"set": {
"salesOwnerId": 1
},
"where": {
"id": {
"_eq": "21"
}
}
}
}
{
"variables": {
"set": {
"salesOwnerId": 1
},
"where": {
"id": {
"_eq": "21"
}
}
}
}
In this corrected payload, the set variable is an object that contains the fields you want to update, and the where variable is an object that specifies the condition for which company(s) to update. Note that the where condition uses the _eq operator to specify that you want to update the company with an id equal to 21. Please ensure that the structure of the set and where variables matches what your GraphQL schema expects. The exact structure might vary based on your schema definitions in Hasura. Remember, the key to resolving this issue is ensuring that the variables you provide in your payload match the expectations of your GraphQL mutation, both in terms of naming and structure. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai55d ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
R
rare-sapphire55d ago
@kapa.ai Thanks i am aware of that, but isn't that how i've structured it in my query? export const COMPANY_TITLE_FORM_MUTATION = gql` mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) { update_companies(_set: $set, where: $where) { returning { id name avatarUrl user { id name avatarUrl } } } }
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- It appears there's been a misunderstanding regarding the structure of the variables in your payload based on the mutation you've provided. Let's clarify the structure required by your mutation and how it should be reflected in your payload. Your mutation is defined as follows:
export const COMPANY_TITLE_FORM_MUTATION = gql`
mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {
update_companies(_set: $set, where: $where) {
returning {
id
name
avatarUrl
user {
id
name
avatarUrl
}
}
}
}`;
export const COMPANY_TITLE_FORM_MUTATION = gql`
mutation CompanyTitleForm($set: companies_set_input!, $where: companies_bool_exp!) {
update_companies(_set: $set, where: $where) {
returning {
id
name
avatarUrl
user {
id
name
avatarUrl
}
}
}
}`;
This mutation expects two variables: - $set: An object of type companies_set_input, which contains the fields you want to update. - $where: An object of type companies_bool_exp, which specifies the condition to match the companies you want to update. From the error message and the payload you've shared, it seems the issue is with how the variables are being passed in the payload, not necessarily with the structure of the mutation itself. The error indicates that the set variable is missing or not correctly structured. Your payload should look something like this:
{
"operationName": "CompanyTitleForm",
"variables": {
"set": {
"salesOwnerId": 1
},
"where": {
"id": {
"_eq": 21
}
}
}
}
{
"operationName": "CompanyTitleForm",
"variables": {
"set": {
"salesOwnerId": 1
},
"where": {
"id": {
"_eq": 21
}
}
}
}
However, based on the error message and the provided context, it seems there might have been a miscommunication or misunderstanding in how you've structured the payload. The payload you've thought you were sending does not seem to match what the server expects or what you've intended based on the mutation's requirements. To ensure clarity, when you execute this mutation, make sure that the variables you pass to it are structured correctly, as shown in the corrected payload example above. This structure directly maps to the $set and $where variables defined in your GraphQL mutation. If you're still encountering issues, double-check the way you're constructing and sending the payload in your application code. Ensure that the variables object in your request precisely matches the structure expected by your GraphQL server, as outlined in the mutation definition. Without the exact code snippet showing how you're executing the mutation (e.g., using Apollo Client, fetch API, etc.), it's challenging to provide more specific guidance. However, the key takeaway is to ensure the structure and content of the variables object in your request match what the mutation expects. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai55d ago
<@309676512054083584> kapa.ai is still learning and improving, please let us know how it did by reacting below
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: Sorry @Konungariket Sverige, I am experiencing especially high traffic right now, please try again. :technologist:
R
rare-sapphire55d ago
@kapa.ai I think the problem is that the Hasura dataprovider is passing the id as a string instead of an Int! Here is the payload {,…} operationName : "CompanyTitleForm" query : "mutation CompanyTitleForm($pk_columns: companies_pk_columns_input!, $_set: companies_set_input!) {\n update_companies_by_pk(pk_columns: $pk_columns, _set: $_set) {\n id\n name\n avatarUrl\n user {\n id\n name\n avatarUrl\n }\n }\n}\n" variables : {id: "2", object: {salesOwnerId: 3}} id : "2" object : {salesOwnerId: 3} salesOwnerId : 3 Giving this error {errors: [{message: "expecting a value for non-nullable variable: "pk_columns"",…}]} errors : [{message: "expecting a value for non-nullable variable: "pk_columns"",…}] 0 : {message: "expecting a value for non-nullable variable: "pk_columns"",…} extensions : {path: "$", code: "validation-failed"} message : "expecting a value for non-nullable variable: "pk_columns"" From the schema "primary key columns input for table: companies" input companies_pk_columns_input {id: Int! } And also this is how i set my dataprovider, into an Int type, but still not working, or maybe i am way off? const gqlDataProvider = dataProvider(client, {idType: "Int"});
K
kapa.ai55d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the details you've provided, it seems there's a misunderstanding in how the variables are structured for your GraphQL mutation, especially in relation to the pk_columns variable expected by your mutation. The error message indicates that the mutation expects a non-nullable variable named pk_columns, but it's not receiving it in the expected format. Let's address this issue step by step. Understanding the Error The error message:
{errors: [{message: "expecting a value for non-nullable variable: "pk_columns"",…}]}
{errors: [{message: "expecting a value for non-nullable variable: "pk_columns"",…}]}
This indicates that the mutation expects a variable named pk_columns which is not being correctly provided in your payload. Correct Payload Structure Given the mutation:
mutation CompanyTitleForm($pk_columns: companies_pk_columns_input!, $_set: companies_set_input!) {
update_companies_by_pk(pk_columns: $pk_columns, _set: $_set) {
id
name
avatarUrl
user {
id
name
avatarUrl
}
}
}
mutation CompanyTitleForm($pk_columns: companies_pk_columns_input!, $_set: companies_set_input!) {
update_companies_by_pk(pk_columns: $pk_columns, _set: $_set) {
id
name
avatarUrl
user {
id
name
avatarUrl
}
}
}
And the schema:
input companies_pk_columns_input {id: Int!}
input companies_pk_columns_input {id: Int!}
Your payload should be structured as follows:
{
"operationName": "CompanyTitleForm",
"variables": {
"pk_columns": {
"id": 2
},
"_set": {
"salesOwnerId": 3
}
}
}
{
"operationName": "CompanyTitleForm",
"variables": {
"pk_columns": {
"id": 2
},
"_set": {
"salesOwnerId": 3
}
}
}
Key Points - The pk_columns variable must be an object that includes the id field with an integer value, matching the companies_pk_columns_input input type from your schema. - The id value in your original payload is a string ("2"), but it should be an integer (2) as per the schema definition. - The object key in your original payload does not match the expected variable names (pk_columns and _set). It should be replaced with the correct structure as shown above. Regarding the idType: "Int" Configuration Your configuration:
const gqlDataProvider = dataProvider(client, {idType: "Int"});
const gqlDataProvider = dataProvider(client, {idType: "Int"});
This configuration indicates to the data provider that ID fields should be treated as integers. However, the issue with your payload is not just about the data type of the id but also about the structure of the variables being passed to the mutation. The data provider configuration specifies the expected data type for ID fields but does not automatically adjust the structure of the variables in your mutation. Conclusion Ensure that when constructing payloads for mutations, the structure of the variables matches exactly what the mutation expects, including the correct naming and data types of variables. This alignment is crucial for the successful execution of mutations in GraphQL, especially when working with strongly typed systems like Hasura. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
More Posts
How to make API call using Data Provider?Considering the following code, how do I make an API call to a specific endpoint such as `stores/bloinferencer data from tableWith the code: ``` import { IResourceComponentsProps } from "@refinedev/core"; import { AntdInferenUnsavedChangesNotifier doesn't work on browser back buttonIt seems that when a form is being exit without save in every scenario the <UnsavedChangesNotifier /Filter nested fields in NestJS-QueryHow do I filter nested fields when using useTable hook from Antd? Dot notation doesn't seem to workCan I use Ant Design and Tailwind together at Refine?Hi there, I am new to the frontend technologies so I am sorry for asking this question. But when I How to do custom auth (REST) ?Hi, I need guidance for making dashboard in next js I want to use custom auth, headlesss ui to styleHi, I need guidance for making dashboardHi, I need guidance for making dashboard in next js I want to use custom auth(REST), headlesss ui toHow to change the default port?How to change the default port?How to get live app updates during Dev timeHi all, I finally decide to ask the question here after 2h of turning around without solution. I'veIt's not validation I need - it's a dataIt's not validation I need - it's a data condition. Basically, before submitting I need the logic toI am on a project with refine core 4.5.8I am on a project with refine core 4.5.8, can I safely update to the recent version? Can't find a chwhat for is refine devtools, how do iwhat for is refine devtools, how do i activate it, where is the documentation for it?Authenticated now working properlyHello, I have my app setup as follows: ``` <Routes> <Route path="/onFinish, being sent as object instead of inputI'm using onFinish to pass input, but it's being sent as an object, how can i change this?Distinct TableHow can I setup my table to only show the first occurrence of a record, e.g. distinct value? ``` <Tfilters in url routeI am loading my default route for a table, however the filters are being added in the url route by dNo application ConnectedWhen i create a new refine project using npm create refine-app@latest ..and a followed all the stepsglobal state and contexti couldn't find anything on documentation regarding global state management and contexts. is there aString filtering on tableAntdesign table, search for sub-string within returned value and display in tableSubstring FilterIs there a way to search a filter and match all records including a sub-string, e.g. searching 703 w