尝试在shopify中验证用户时,出现错误:Field';CustomerAccessTokenCreateInput';不';类型'上不存在;突变';
我在我的应用程序中使用node.js和尝试在shopify中验证用户时,出现错误:Field';CustomerAccessTokenCreateInput';不';类型'上不存在;突变';,shopify,shopify-api-node,Shopify,Shopify Api Node,我在我的应用程序中使用node.js和shopifAPI node(v3.2.0),以验证客户登录以及shopify的其他功能。根据shopify文档(),我正在使用GraphQL访问shopify API。 我的代码如下所示:- const Shopify = require('shopify-api-node'); const shopify = new Shopify({ shopName: process.env.SHOPIFY_DOMAIN_NAME, apiKey: pro
shopifAPI node
(v3.2.0),以验证客户登录以及shopify的其他功能。根据shopify文档(),我正在使用GraphQL访问shopify API。
我的代码如下所示:-
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: process.env.SHOPIFY_DOMAIN_NAME,
apiKey: process.env.SHOPIFY_API_KEY,
password: process.env.SHOPIFY_API_KEY_PASSWORD
});
const query = `mutation {
customerAccessTokenCreate (input: {
email: "user@mail.com",
password: "password123"
}
)
{
customerAccessToken {
accessToken
expiresAt
}
customerUserErrors {
code
field
message
}
}
}`;
shopify
.graphql(query)
.then((output) => {
console.log(output);
})
.catch((err) => {
console.error(err)
});
在此之后,我得到以下错误:-
Error: Field 'customerAccessTokenCreate' doesn't exist on type 'Mutation'
at got.then (/Users/admin/Documents/Code/shopify-node-app/node_modules/shopify-api-node/index.js:239:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
locations: [ { line: 2, column: 5 } ],
path: [ 'mutation', 'customerAccessTokenCreate' ],
extensions:
{ code: 'undefinedField',
typeName: 'Mutation',
fieldName: 'customerAccessTokenCreate' }
甚至我也从邮递员那里得到了同样的东西
任何帮助都将不胜感激。有两种类型的GraphQL:
- 店面图ql-
- 管理图ql-
storefrontAccessToken
方法创建店面访问令牌
因此,您需要确保使用了正确的API
如果您计划使用店面API,则不应使用NodeJS,只需创建一个私有应用程序(从Admin->app->private app),该应用程序将为您提供一个店面访问令牌(如果您在底部启用该令牌并选择适当的作用域),可直接在前端使用
如果您计划使用管理API,则需要创建一个公共应用程序并将其托管,然后您可以使用NodeJS并通过Shopify中的代理传递信息
总结
您正在向店面API发出请求,同时使用管理API库