Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work for me at all #20

Open
guidoffm opened this issue Sep 29, 2022 · 2 comments
Open

Does not work for me at all #20

guidoffm opened this issue Sep 29, 2022 · 2 comments

Comments

@guidoffm
Copy link

I have tried a simple AWS Lambda that executes a query against AppSync to return data and also tried a query that invokes a mutation to add new data.

For both the query just returns null

But there are no error messages displayed.

AWS cloudwatch reads:

67548b14-2c8e-40fa-8437-ca2e79c00cbd GraphQL Query: query MyQuery {
  listGuido1S {
    items {
      id
      name
    }
  }
}
, Operation: null, Variables: 
{}

Interesting: Operation is always null.

The code I use is:

import AppsyncClient from 'appsync-client';
import gql from "graphql-tag";


export async function handler(evt: any, ctx: any) {

//     const query = gql(`
// mutation MyMutation($x: CreateGuido1Input!) {
//     createGuido1(input: $x ) {
//         name
//         id
//     }
// }
// `);

const query = gql(`
query MyQuery {
    listGuido1S {
      items {
        id
        name
      }
    }
  }
  `);

    const client = new AppsyncClient({
        apiUrl: process.env.API_URL
    });

    try {
        const res = await client.request({
            query: query,
            variables: {}
        });

        return res;
    } catch (err) {
        console.error('error: ', err);
        throw (err);
    }

}

The operations succeed when invoked via AWS console.

@guidoffm
Copy link
Author

schema {
  query: Query
  mutation: Mutation
  subscription: Subscription
}

type Guido1 {
  id: ID!
  name: String!
}

type Guido1Connection {
  items: [Guido1]
  nextToken: String
}

type Mutation {
  createGuido1(input: CreateGuido1Input!): Guido1
  deleteGuido1(input: DeleteGuido1Input!): Guido1
  updateGuido1(input: UpdateGuido1Input!): Guido1
}

type Query {
  getGuido1(id: ID!): Guido1
  listGuido1S(filter: TableGuido1FilterInput, limit: Int, nextToken: String): Guido1Connection
}

type Subscription {
  onCreateGuido1(id: ID, name: String): Guido1 @aws_subscribe(mutations : ["createGuido1"])
  onDeleteGuido1(id: ID, name: String): Guido1 @aws_subscribe(mutations : ["deleteGuido1"])
  onUpdateGuido1(id: ID, name: String): Guido1 @aws_subscribe(mutations : ["updateGuido1"])
}

input CreateGuido1Input {
  name: String!
}

input DeleteGuido1Input {
  id: ID!
}

input TableBooleanFilterInput {
  eq: Boolean
  ne: Boolean
}

input TableFloatFilterInput {
  between: [Float]
  contains: Float
  eq: Float
  ge: Float
  gt: Float
  le: Float
  lt: Float
  ne: Float
  notContains: Float
}

input TableGuido1FilterInput {
  id: TableIDFilterInput
  name: TableStringFilterInput
}

input TableIDFilterInput {
  beginsWith: ID
  between: [ID]
  contains: ID
  eq: ID
  ge: ID
  gt: ID
  le: ID
  lt: ID
  ne: ID
  notContains: ID
}

input TableIntFilterInput {
  between: [Int]
  contains: Int
  eq: Int
  ge: Int
  gt: Int
  le: Int
  lt: Int
  ne: Int
  notContains: Int
}

input TableStringFilterInput {
  beginsWith: String
  between: [String]
  contains: String
  eq: String
  ge: String
  gt: String
  le: String
  lt: String
  ne: String
  notContains: String
}

input UpdateGuido1Input {
  id: ID!
  name: String
}

@alan-cooney
Copy link
Member

Related to #16 - we need better error handling to find out what is going in. If you have time please do submit a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants