Generate Subscription with arguments in AWS AppSync with GraphQL Transform
I’m currently using GraphQL transform lib to generate all my schema.
I have a model defined like this:
type Feedback @model {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
and the auto-generated subscription schema is like this:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
I would like to have an argument for the subscription so that I can subscribe to that event only, like this:
type Subscription {
onCreateFeedback(eventId: ID): Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
What do I need to do to get this subscription auto generated? Thanks!
aws-appsync graphql-subscriptions
add a comment |
I’m currently using GraphQL transform lib to generate all my schema.
I have a model defined like this:
type Feedback @model {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
and the auto-generated subscription schema is like this:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
I would like to have an argument for the subscription so that I can subscribe to that event only, like this:
type Subscription {
onCreateFeedback(eventId: ID): Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
What do I need to do to get this subscription auto generated? Thanks!
aws-appsync graphql-subscriptions
add a comment |
I’m currently using GraphQL transform lib to generate all my schema.
I have a model defined like this:
type Feedback @model {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
and the auto-generated subscription schema is like this:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
I would like to have an argument for the subscription so that I can subscribe to that event only, like this:
type Subscription {
onCreateFeedback(eventId: ID): Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
What do I need to do to get this subscription auto generated? Thanks!
aws-appsync graphql-subscriptions
I’m currently using GraphQL transform lib to generate all my schema.
I have a model defined like this:
type Feedback @model {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
and the auto-generated subscription schema is like this:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
I would like to have an argument for the subscription so that I can subscribe to that event only, like this:
type Subscription {
onCreateFeedback(eventId: ID): Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
What do I need to do to get this subscription auto generated? Thanks!
aws-appsync graphql-subscriptions
aws-appsync graphql-subscriptions
asked Jan 19 at 8:55
odieatlaodieatla
3552723
3552723
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Customizing the subscription fields arguments is currently not supported. The only supported customization is to create multiple subscription fields tied to a single mutation.
Example:
type Feedback @model(subscriptions: { onCreate: ["onCreateFeedback", "onCreateFeedbackById"] }) {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
will generate for the subscription type:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
onCreateFeedbackById: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
but then you will have to add the eventId argument manually on the onCreateFeedbackById field.
Though, I would suggest to open a feature request in https://github.com/aws-amplify/amplify-cli/issues
add a comment |
As @Tinou correctly outlines, you can rename and turn off subscription fields that are generated by @model using the subscriptions arg but you also the ability to create custom subscriptions by adding a Subscription type to your schema.
type Subscription {
customField(arg: String): String @aws_subscribe(mutations:["customPublish"])
}
With this approach, you can add any fields and arguments that you need.
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54265505%2fgenerate-subscription-with-arguments-in-aws-appsync-with-graphql-transform%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Customizing the subscription fields arguments is currently not supported. The only supported customization is to create multiple subscription fields tied to a single mutation.
Example:
type Feedback @model(subscriptions: { onCreate: ["onCreateFeedback", "onCreateFeedbackById"] }) {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
will generate for the subscription type:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
onCreateFeedbackById: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
but then you will have to add the eventId argument manually on the onCreateFeedbackById field.
Though, I would suggest to open a feature request in https://github.com/aws-amplify/amplify-cli/issues
add a comment |
Customizing the subscription fields arguments is currently not supported. The only supported customization is to create multiple subscription fields tied to a single mutation.
Example:
type Feedback @model(subscriptions: { onCreate: ["onCreateFeedback", "onCreateFeedbackById"] }) {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
will generate for the subscription type:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
onCreateFeedbackById: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
but then you will have to add the eventId argument manually on the onCreateFeedbackById field.
Though, I would suggest to open a feature request in https://github.com/aws-amplify/amplify-cli/issues
add a comment |
Customizing the subscription fields arguments is currently not supported. The only supported customization is to create multiple subscription fields tied to a single mutation.
Example:
type Feedback @model(subscriptions: { onCreate: ["onCreateFeedback", "onCreateFeedbackById"] }) {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
will generate for the subscription type:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
onCreateFeedbackById: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
but then you will have to add the eventId argument manually on the onCreateFeedbackById field.
Though, I would suggest to open a feature request in https://github.com/aws-amplify/amplify-cli/issues
Customizing the subscription fields arguments is currently not supported. The only supported customization is to create multiple subscription fields tied to a single mutation.
Example:
type Feedback @model(subscriptions: { onCreate: ["onCreateFeedback", "onCreateFeedbackById"] }) {
id: ID!
event: Event! @connection(name: "EventFeedbacks")
submittedDate: AWSDateTime!
}
will generate for the subscription type:
type Subscription {
onCreateFeedback: Feedback
@aws_subscribe(mutations: ["createFeedback"])
onCreateFeedbackById: Feedback
@aws_subscribe(mutations: ["createFeedback"])
}
but then you will have to add the eventId argument manually on the onCreateFeedbackById field.
Though, I would suggest to open a feature request in https://github.com/aws-amplify/amplify-cli/issues
answered Jan 19 at 23:50
TinouTinou
4,13441319
4,13441319
add a comment |
add a comment |
As @Tinou correctly outlines, you can rename and turn off subscription fields that are generated by @model using the subscriptions arg but you also the ability to create custom subscriptions by adding a Subscription type to your schema.
type Subscription {
customField(arg: String): String @aws_subscribe(mutations:["customPublish"])
}
With this approach, you can add any fields and arguments that you need.
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
add a comment |
As @Tinou correctly outlines, you can rename and turn off subscription fields that are generated by @model using the subscriptions arg but you also the ability to create custom subscriptions by adding a Subscription type to your schema.
type Subscription {
customField(arg: String): String @aws_subscribe(mutations:["customPublish"])
}
With this approach, you can add any fields and arguments that you need.
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
add a comment |
As @Tinou correctly outlines, you can rename and turn off subscription fields that are generated by @model using the subscriptions arg but you also the ability to create custom subscriptions by adding a Subscription type to your schema.
type Subscription {
customField(arg: String): String @aws_subscribe(mutations:["customPublish"])
}
With this approach, you can add any fields and arguments that you need.
As @Tinou correctly outlines, you can rename and turn off subscription fields that are generated by @model using the subscriptions arg but you also the ability to create custom subscriptions by adding a Subscription type to your schema.
type Subscription {
customField(arg: String): String @aws_subscribe(mutations:["customPublish"])
}
With this approach, you can add any fields and arguments that you need.
answered Jan 21 at 19:19
mparismparis
1,68676
1,68676
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
add a comment |
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
Before I was having error message like 'unknown directive @aws_subscribe'. Now I can compile after I switch to multienv branch of @aws-amplify/cli. Now the subscription with argument can be generated now, but no result is received after a mutation. Do I need to write a resolver for the subscription?
– odieatla
Jan 22 at 19:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54265505%2fgenerate-subscription-with-arguments-in-aws-appsync-with-graphql-transform%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown