我能够通过Admin成功地提取订单。现在,我正在创建一个定制的create小部件,并使用与获取订单所用的提取方法相同的方法,但使用posting来创建客户。以下是提取呼叫:
const shopifyUserQuery = `
query {
customer {
first_name: ${values.firstName},
last_name: ${values.lastName},
email: ${values.email},
verified_email: true,
password: ${values.password}
password_confirmation: ${values.password},
send_email_welcome = false;
}
}
`
const shopifyUser = await fetch(process.env.SHOPIFY_ADMIN_API_URL, {
'body': shopifyUserQuery,
'method': 'post',
'headers': {
'X-Shopify-Access-Token': shopifyAdminAccessToken,
'Content-Type': 'application/graphql',
},
}).then((res) => console.log(res))
现在,响应是非常奇怪的-没有错误,没有什么只是压缩文件中的奇怪的混合内容:
<ref *1> Gunzip {
_writeState: Uint32Array(2) [ 0, 0 ],
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: null,
ended: false,
endEmitted: false,
reading: false,
constructed: true,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
destroyed: false,
errored: null,
closed: false,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: null
},
_events: [Object: null prototype] {
prefinish: [Function: prefinish],
unpipe: [Function: onunpipe],
error: [ [Function: onerror], [Function (anonymous)] ],
close: [Function: bound onceWrapper] { listener: [Function: onclose] },
finish: [Function: bound onceWrapper] { listener: [Function: onfinish] }
},
_eventsCount: 5,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 109,
writing: true,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: [Function: nop],
writelen: 109,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 1,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: true,
bytesWritten: 0,
_handle: Zlib {
onerror: [Function: zlibOnError],
buffer: <Buffer 1f 8b 08 00 00 00 00 00 04 03 25 8c 31 0a 80 30 10 04 bf 72 6c a5 10 6c 42 52 e4 15 f6 9a e2 90 20 42 bc 83 44 ab e0 df 0d ca 56 c3 30 db 90 4a d1 52 ... 59 more bytes>,
cb: [Function (anonymous)],
availOutBefore: 16384,
availInBefore: 109,
inOff: 0,
flushFlag: 2,
[Symbol(owner_symbol)]: [Circular *1]
},
_outBuffer: <Buffer 7b 22 65 72 72 6f 72 73 22 3a 5b 7b 22 6d 65 73 73 61 67 65 22 3a 22 50 61 72 73 65 20 65 72 72 6f 72 20 6f 6e 20 5c 22 2e 5c 22 20 28 65 72 72 6f 72 ... 16334 more bytes>,
_outOffset: 0,
_chunkSize: 16384,
_defaultFlushFlag: 2,
_finishFlushFlag: 2,
_defaultFullFlushFlag: 3,
_info: undefined,
_maxOutputLength: 4294967296,
_level: -1,
_strategy: 0,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null,
[Symbol(kError)]: null
}
同样,这个管理令牌密钥也能工作,但即使存在范围或烫发问题(我反复检查了我的应用程序是否有客户读和写范围),我也希望有一个更好的错误。任何帮助都是非常感谢的。
发布于 2022-11-22 10:31:35
Shopify GraphQL中的查询操作是get请求的类型,您只能获得所需的查询列表。
要编辑或更新存储中的任何内容,您需要使用突变操作(管理api需要)
mutation test {
customerCreate(input: {firstName: "", lastName: "", phone: "", email: ""})
}
要获得更多的清晰度,请访问- 共享GraphQL
在图像中,您可以看到如何添加突变操作。
https://stackoverflow.com/questions/74522568
复制相似问题