GraphQL-变量ID不能为非输入类型Float

时间:2019-07-31 19:10:13

标签: graphql react-apollo apollo-client graphql-js

可能是一个绝对的初学者问题:

import gql from "graphql-tag";
import { graphql } from "react-apollo";

export const productQuery = gql`
    query Product($id: Float!){
        getProduct(id:$id){
            name,
            description,
            variants{price}
        }
    }
`;

export default graphql(productQuery, {
  options: props => ({ variables: { "id": 1 } })
});

我在开发人员控制台中收到此错误消息:

"GraphQL error: Variable '$id' cannot be non input type 'Float!'. (line 1, column 20):
query Product($id: Float!) {
                   ^
GraphQL error: Unknown type 'Float'. (line 1, column 20):
query Product($id: Float!) {
                   ^
GraphQL error: Cannot query field 'getProduct' on type 'Query'. (line 2, column 3):
  getProduct(id: $id) {
  ^"

如果我使用graphQLi工具发送查询,则此查询没有问题。 怎么了?

0 个答案:

没有答案
相关问题