Skip to content

AWS directives #1659

@nealyip

Description

@nealyip

https://docs.aws.amazon.com/appsync/latest/devguide/real-time-data.html

Is there any way to implement the @aws_subscribe?

For example,

import {
    GraphQLSchema,
    GraphQLObjectType,
    GraphQLString,
    printSchema,
    GraphQLFieldConfig
} from 'graphql';

export function handler() {

    const schema = new GraphQLSchema({
        query: new GraphQLObjectType({
            name: 'Query',
            fields: {
                hello: {
                    type: GraphQLString,
                    resolve() {
                        return 'world';
                    }
                }
            }
        }),
        subscription: new GraphQLObjectType({
            name: 'Subscription',
            fields: {
                subscription:<GraphQLFieldConfig<any, any>> {
                    type: GraphQLString,
                    resolve() {
                        return 'world';
                    }
                }
            }
        })
    });

    const x = printSchema(schema);

    console.log(x);
}

will output

type Query {
  hello: String
}

type Subscription {
  subscription: String
}

How can I make it like

type Query {
  hello: String
}

type Subscription {
  subscription: String
     @aws_subscribe(mutations: ["addPost"])
}

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions