本文整理汇总了TypeScript中graphql-relay.mutationWithClientMutationId函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mutationWithClientMutationId函数的具体用法?TypeScript mutationWithClientMutationId怎么用?TypeScript mutationWithClientMutationId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mutationWithClientMutationId函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: mutationWithClientMutationId
fields: () => ({
node: nodeField
})
});
// Mutations
// mutationWithClientMutationId takes a name, input fields, output fields, and a mutation method to map from the input fields to the output fields, performing the mutation along the way.
// It then creates and returns a field configuration that can be used as a top-level field on the mutation type.
const gifcm: GraphQLInputFieldConfigMap = {};
const gfcm: GraphQLFieldConfigMap<any, any> = {};
mutationWithClientMutationId({
name: "M",
description: "D",
inputFields: gifcm,
mutateAndGetPayload: (object: any,
ctx: any,
info: GraphQLResolveInfo) => {
return new Promise<string>((resolve) => {
resolve(info.fieldName);
});
},
outputFields: gfcm,
});
// An example usage of these methods from the test schema:
const data: any = {};
var shipMutation = mutationWithClientMutationId({
name: 'IntroduceShip',
inputFields: {
shipName: {
type: new GraphQLNonNull(GraphQLString)
},
factionId: {
开发者ID:EmmaRamirez,项目名称:DefinitelyTyped,代码行数:31,代码来源:graphql-relay-tests.ts
示例2: mutationWithClientMutationId
export const FulfillOrderAtOnceMutation = mutationWithClientMutationId({
name: "FulfillOrderAtOnce",
description:
"Fulfills an Order with one fulfillment by setting this fulfillment to all line items of this order",
inputFields: FulfillOrderAtOnceInputType.getFields(),
outputFields: {
result: {
type: OrderReturnType,
resolve: order => order,
},
},
mutateAndGetPayload: (
{ orderId, fulfillment },
context,
{ rootValue: { accessToken, exchangeSchema } }
) => {
if (!accessToken) {
return new Error("You need to be signed in to perform this action")
}
const mutation = `
mutation fulfillOrderAtOnce($orderId: ID!, $fulfillment: EcommerceFulfillmentAttributes!) {
ecommerce_fulfillAtOnce(input: {
id: $orderId,
fulfillment: $fulfillment
}) {
order {
id
code
currencyCode
state
partnerId
userId
requestedFulfillment {
${RequestedFulfillmentFragment}
}
itemsTotalCents
shippingTotalCents
taxTotalCents
commissionFeeCents
transactionFeeCents
buyerTotalCents
sellerTotalCents
updatedAt
createdAt
stateUpdatedAt
stateExpiresAt
lineItems{
edges{
node{
id
priceCents
artworkId
editionSetId
quantity
fulfillments{
edges{
node{
id
courier
trackingId
estimatedDelivery
}
}
}
}
}
}
}
errors
}
}
`
return graphql(exchangeSchema, mutation, null, context, {
orderId,
fulfillment,
}).then(result => {
if (result.errors) {
throw Error(result.errors.map(d => d.message))
}
const { order, errors } = result.data.ecommerce_fulfillAtOnce
return {
order,
errors,
}
})
},
})
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:88,代码来源:fulfill_order_at_once_mutation.ts
示例3: submissionUpdateLoader
import { mutationWithClientMutationId } from "graphql-relay"
import { SubmissionType } from "./submission"
import { omit } from "lodash"
export const config = {
name: "UpdateSubmissionMutation",
description: "Update a consignment using Convection",
inputFields: {
...omit(SubmissionType.getFields(), ["__id", "_id", "artist"]),
} as any,
outputFields: {
consignment_submission: {
type: SubmissionType,
resolve: submission => submission,
},
},
mutateAndGetPayload: (
submission,
_request,
{ rootValue: { submissionUpdateLoader } }
) => {
if (!submissionUpdateLoader) return null
return submissionUpdateLoader(submission.id, submission)
},
}
export default mutationWithClientMutationId(config)
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:26,代码来源:update_submission_mutation.ts
示例4: createMessage
/* MUTATIONS */
/**********************************************************************/
/* NOTE: Relay injects the user session to the rootValue `args.rootValue.id`
mutation { createMessage(input: {body: "hello world!" clientMutationId: "1"}) {
message { body, createdAt, user { name } }
}}
*/
const CreateMessageMutation = R.mutationWithClientMutationId({
name: 'CreateMessage',
inputFields: {
body: { type: new GQL.GraphQLNonNull(GQL.GraphQLString) }
},
outputFields: {
message: {
type: MessageType,
resolve: (obj): any => obj
}
},
mutateAndGetPayload: async (msg, args): Promise<any> => {
const newMsg = { body: msg.body, userId: args.rootValue.id }
try {
return await new db.Message(newMsg).save()
} catch (e) { throw new GQL.GraphQLError(e.message) }
}
})
/**********************************************************************/
/* ROOTS */
/**********************************************************************/
const RootMutationType = new GQL.GraphQLObjectType({
name: 'RootMutation',
fields: (): GQL.GraphQLFieldConfigMap => ({
开发者ID:duataud,项目名称:PlayApp,代码行数:32,代码来源:mainSchema.ts
示例5: mutationWithClientMutationId
export const CreateOrderWithArtworkMutation = mutationWithClientMutationId({
name: "CreateOrderWithArtwork",
description: "Creates an order with an artwork",
inputFields: CreateOrderInputType.getFields(),
outputFields: {
orderOrError: {
type: OrderOrFailureUnionType,
},
},
mutateAndGetPayload: (
{ artworkId, editionSetId, quantity },
context,
{ rootValue: { accessToken, exchangeSchema } }
) => {
if (!accessToken) {
return new Error("You need to be signed in to perform this action")
}
const mutation = gql`
mutation createOrderWithArtwork(
$artworkId: String!
$editionSetId: String
$quantity: Int
) {
ecommerce_createOrderWithArtwork(
input: {
artworkId: $artworkId
editionSetId: $editionSetId
quantity: $quantity
}
) {
orderOrError {
... on EcommerceOrderWithMutationSuccess {
order {
id
buyerTotalCents
code
commissionFeeCents
createdAt
currencyCode
itemsTotalCents
partnerId
sellerTotalCents
requestedFulfillment {
${RequestedFulfillmentFragment}
}
shippingTotalCents
state
stateExpiresAt
stateUpdatedAt
taxTotalCents
transactionFeeCents
updatedAt
userId
lineItems {
edges {
node {
id
priceCents
artworkId
editionSetId
quantity
}
}
}
}
}
... on EcommerceOrderWithMutationFailure {
error {
description
}
}
}
}
}
`
return (
graphql(exchangeSchema, mutation, null, context, {
artworkId,
editionSetId,
quantity,
})
// Because the error types are represented in the type system we
// can always assume that data is being used. If the call to Exchange
// fails then the error would have stopped execution before here
.then(result => result.data!.ecommerce_createOrderWithArtwork)
)
},
})
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:90,代码来源:create_order_with_artwork_mutation.ts
示例6: mutationWithClientMutationId
export const SetOrderPaymentMutation = mutationWithClientMutationId({
name: "SetOrderPayment",
description: "Sets payment information on an order",
inputFields: SetOrderPaymentInputType.getFields(),
outputFields: {
result: {
type: OrderReturnType,
resolve: order => order,
},
},
mutateAndGetPayload: (
{ orderId, creditCardId },
context,
{ rootValue: { accessToken, exchangeSchema } }
) => {
if (!accessToken) {
return new Error("You need to be signed in to perform this action")
}
const mutation = gql`
mutation setOrderPayment($orderId: ID!, $creditCardId: String!) {
ecommerce_setPayment(input: {
id: $orderId,
creditCardId: $creditCardId,
}) {
order {
id
code
currencyCode
state
partnerId
userId
requestedFulfillment {
${RequestedFulfillmentFragment}
}
itemsTotalCents
shippingTotalCents
taxTotalCents
commissionFeeCents
transactionFeeCents
buyerTotalCents
sellerTotalCents
updatedAt
createdAt
stateUpdatedAt
stateExpiresAt
lineItems{
edges{
node{
id
priceCents
artworkId
editionSetId
quantity
}
}
}
}
errors
}
}
`
return graphql(exchangeSchema, mutation, null, context, {
orderId,
creditCardId,
}).then(result => {
if (result.errors) {
throw Error(result.errors.map(d => d.message))
}
const { order, errors } = result.data.ecommerce_setPayment
return {
order,
errors,
}
})
},
})
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:76,代码来源:set_order_payment_mutation.ts
示例7: mutationWithClientMutationId
export let createSeedMutation: GraphQLFieldConfig = mutationWithClientMutationId({
name: 'CreateSeed',
inputFields: {
name: { type: new GraphQLNonNull(GraphQLString) },
description: { type: new GraphQLNonNull(GraphQLString) },
location: { type: new GraphQLNonNull(GraphQLString) },
userId: { type: new GraphQLNonNull(GraphQLString) },
cross: { type: crossSeedObject }
},
outputFields: {
seedEdge: {
type: seedConnection.edgeType,
resolve: (obj: InsertOneWriteOpResult) => ({ node: obj.ops[0], cursor: obj.insertedId })
},
store: {
type: storeType,
resolve: () => store
}
},
mutateAndGetPayload: (seed: ISeed, context) => {
return (async () => {
seed.createdAt = Date.now();
seed.userId = fromGlobalId(seed.userId).id;
let counter: ISequenceValue = await getSeedNextSequence('seedCounter', context.db);
seed.index = counter.value.seq;
if (seed.cross.first !== undefined) {
let firstSeed: ISeed = await context.db.collection('seeds').find({ index: seed.cross.first }).limit(1).next();
seed.cross.secondIndex = firstSeed.cross.secondIndex;
if (seed.cross.type === 'G') {
seed.cross.name = firstSeed.cross.name;
seed.cross.index = firstSeed.cross.index + 1;
} else {
seed.cross.name = seed.cross.type;
seed.cross.index = 1;
if (seed.cross.type === 'BC' || seed.cross.type === 'OC') {
seed.cross.secondIndex = (firstSeed.cross.secondIndex || 0) + 1;
}
}
} else {
seed.cross.index = 0;
seed.cross.name = seed.cross.type;
}
return context.db.collection('seeds').insertOne(seed);
})();
}
});
开发者ID:pjayala,项目名称:labseed,代码行数:51,代码来源:seed.mutation.ts
示例8: mutationWithClientMutationId
createdAt?: number;
updatedAt?: number;
}
export let createUserMutation: any = mutationWithClientMutationId({
name: 'CreateUser',
inputFields: {
login: { type: new GraphQLNonNull(GraphQLString) },
name: { type: new GraphQLNonNull(GraphQLString) },
surname: { type: new GraphQLNonNull(GraphQLString) },
email: { type: new GraphQLNonNull(GraphQLString) }
},
outputFields: {
userEdge: {
type: userConnection.edgeType,
resolve: (obj: InsertOneWriteOpResult) => ({ node: obj.ops[0], cursor: obj.insertedId })
},
store: {
type: storeType,
resolve: () => store
}
},
mutateAndGetPayload: (user: IUser, context: IContext) => {
user.createdAt = Date.now();
return context.db.collection('users').insertOne(user);
}
});
export let updateUserMutation: any = mutationWithClientMutationId({
name: 'UpdateUser',
开发者ID:pjayala,项目名称:labseed,代码行数:31,代码来源:user.mutation.ts
示例9: mutationWithClientMutationId
export default mutationWithClientMutationId({
name: "CreateGeminiEntryForAsset",
description: "Attach an gemini asset to a consignment submission",
inputFields: {
source_key: {
type: new GraphQLNonNull(GraphQLString),
description: "The path to the file",
},
template_key: {
type: new GraphQLNonNull(GraphQLString),
description: "The template key, this is `name` in the asset request",
},
source_bucket: {
type: new GraphQLNonNull(GraphQLString),
description: "The S3 bucket where the file was uploaded",
},
metadata: {
type: new GraphQLNonNull(GraphQLJSON),
description:
"Additional JSON data to pass through gemini, should deiinitely contain an `id` and a `_type`",
},
},
outputFields: {
asset: {
type: GeminiEntryType,
resolve: credentials => credentials,
},
},
mutateAndGetPayload: (
{ name, template_key, source_key, source_bucket, metadata },
_request,
{ rootValue: { createNewGeminiEntryAssetLoader } }
) => {
if (!createNewGeminiEntryAssetLoader) return null
return createNewGeminiEntryAssetLoader({
name,
template_key,
source_key,
source_bucket,
metadata,
})
},
})
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:43,代码来源:finalize_asset_mutation.ts
示例10: mutationWithClientMutationId
export const recordArtworkViewMutation = mutationWithClientMutationId({
name: "RecordArtworkView",
description: "Records an artwork view.",
inputFields: {
artwork_id: {
type: new GraphQLNonNull(GraphQLString),
},
},
outputFields: {
artwork_id: {
type: new GraphQLNonNull(GraphQLString),
resolve: ({ artwork_id }) => artwork_id,
},
},
mutateAndGetPayload: (
{ artwork_id },
_request,
{ rootValue: { recordArtworkViewLoader } }
) => {
if (!recordArtworkViewLoader) {
throw new Error(
"Missing recordArtworkViewLoader. Check that `X-Access-Token` and `X-User-Id` headers are set."
)
}
return recordArtworkViewLoader({ artwork_id }).then(() => {
return { artwork_id }
})
},
})
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:29,代码来源:recently_viewed_artworks.ts
注:本文中的graphql-relay.mutationWithClientMutationId函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论