The following FQL always returns empty JSON response. I have all the necessary permissions set up and I tried all the other suggestions mentioned here.
What else can I try?
SELECT metric, value FROM insights WHERE object_id= '100002643961484_444481312316664' AND metric='post_impressions' AND period = 0
Also
SELECT post_id, impressions FROM stream WHERE source_id = me()
returns null for all the posts. Are there any other restrictions except permissions that make requests return null and empty values?
{
"post_id": "100002643961484_444585178972944",
"impressions": null
},
{
"post_id": "100002643961484_444481312316664",
"impressions": null
},
{
"post_id": "100002643961484_444481068983355",
"impressions": null
},
Related
Background
Documentation for AWS CloudWatch Metric Filter Patterns seems to be pretty light. This seems to be the only source out there:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html
Looking at the above page, it seems that you can search for fields that are null values & you can search for missing fields but you can't search for fields that are present but are not null.
For example, here's log that i'm pushing to cloudwatch:
{
"userId": "my_user",
"externalUserId": null,
"logDirection": "INBOUND",
"type": "RESPONSE",
"layerIdentifier": "my_id"
}
I want to create a metric for every event that has "exernalUserId" not set to null.
I can do:
{ $.externalUserId IS NULL } this will match the above event
{ $.externalUserId = * } this will also match the above event
{ $.externalUserId != "blah" } this will also match the above event
What I want to do is:
{ $.externalUserId IS NOT NULL }, this gives me an invalid syntax error
{ $.externalUserId != "null" }, this matches the above event (which I don't want)
{ $.externalUserId != null }, this gives me an invalid syntax error
Question
Is it possible to filter for events where the externalUserId value is not set to null? i.e. I want to find events where this value is a string
tried all of the above, was hoping for a filter pattern that hits non null field values
I'm using AppSync and DynamoDB. Is there a way to suppress the non-null error and return partial data for a graphql query whose result omits a non-null field? For example if I run the following query:
query GetPerson {
getPerson(id: "123") {
name
active
}
}
And in my AppSync resolver I have logic that decides whether or not to return the value for active. If I decide not to return active, then I get the following response:
{
"data": {
"getPerson": null
},
"errors": [
{
"path": [
"getPerson",
"active"
],
"locations": null,
"message": "Cannot return null for non-nullable type: 'Boolean' within parent 'Person' (/getPerson/active)"
}
]
}
because in my schema the active field is non-null. Is there any to suppress this error and return the partial data (i.e. the value for name)? I would like to get a response like this instead:
{
"data": {
"getPerson": {
"name": "Jane Doe"
}
},
"errors": [
{
"path": [
"getPerson",
"active"
],
"locations": null,
"message": "Cannot return null for non-nullable type: 'Boolean' within parent 'Person' (/getPerson/active)"
}
]
}
No. A non-null field should never return null.
If the field is requested and it resolves to null, GraphQL will return an error. Because the field cannot be null, GraphQL will return null for the parent field instead. If that field is also non-null, it will return null for that field's parent... and so on, until it hits either a nullable parent field or the root (i.e. data). This behavior is described in the spec:
If an error is thrown while resolving a field, it should be treated as though the field returned null, and an error must be added to the "errors" list in the response.
If the result of resolving a field is null (either because the function to resolve the field returned null or because an error occurred), and that field is of a Non-Null type, then a field error is thrown. The error must be added to the "errors" list in the response...
Since Non-Null type fields cannot be null, field errors are propagated to be handled by the parent field. If the parent field may be null then it resolves to null, otherwise if it is a Non-Null type, the field error is further propagated to it’s parent field...
If all fields from the root of the request to the source of the field error return Non-Null types, then the "data" entry in the response should be null.
If it's possible for active to be null, then you should not make it non-nullable in your schema.
With thanks in advance as this is probably a 101 question - I can't find an answer anywhere.
I've set up what I think is a simple example of AppSync and DynamoDB.
In DynamoDB I have a categorys table, with items of the form
{
slug: String!,
nm: String,
nmTrail: String,
...
}
So - no id field. slug is he primary partition key, not null and expected to be unique (is unique in the data I've got loaded so far).
I've set up a simplified AppSync schema in line with the above definition and
a resolver...
{
"version": "2017-02-28",
"operation" : "GetItem",
"key" : {
"slug" : { "S" : "${context.arguments.slug}" }
}
}
A query such as
query GoGetOne {
getCategory(slug: "Wine") {
nm
}
}
Works fine - returning the nm value for the correct item in categorys - similarly I can add any of the other properties in categorys to return them (e.g. nmTrail) except slug.
If I add slug (the Primary Partition Key, a non-nullable String) to the result set then I get a DynamoDB:AmazonDynamoDBException of the provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException.
If I scan/query/filter the table in DynamoDB all is good.
Most of the AWS examples use an id: ID! field in the 'get one' examples and also ask for it as a returned item.
update1 in response to KDs request
My update mutation schema is:
type Mutation {
putCategory(
slug: String!,
nm: String,
nmTrail: String,
mainCategorySlug: String,
mainCategoryNm: String,
parentCategorySlug: String,
parentCategoryNm: String
): Category
}
No resolver associated with that and (obviously) therefore haven't used mutation to put anything yet - just trying to get batch uploaded data to begin with.
/update1
What am I missing?
I tried to reproduce your API as much as I could and it works for me.
Category DynamoDB table
Schema:
type Query {
getCategory(slug: String!): Category
}
type Category {
slug: String
nm: String
nmTrail: String
}
Resolver on Query.getCategory request template:
{
"version": "2017-02-28",
"operation": "GetItem",
"key": {
"slug": $util.dynamodb.toDynamoDBJson($ctx.args.slug),
}
}
Resolver on Query.getCategory response template:
$util.toJson($ctx.result)
Query:
query GoGetOne {
getCategory(slug: "Wine") {
slug
nm
}
}
Results
{
"data": {
"getCategory": {
"slug": "Wine",
"nm": "Wine1-nm"
}
}
}
Below is the response from my spatial view query in Couchbase by providing bounding box parameters:
{
"rows":[
{
"geometry":{
"type":"Point",
"coordinates":[
-71.10364,
42.381411
]
},
"value":{
"location":{
"type":"Point",
"coordinates":[
-71.10364,
42.381411
]
},
"name":"test",
"visibility":"public",
},
"id":"test",
"key":[
[
-71.10364,
-71.10364
],
[
42.381411,
42.381411
]
]
}
]
}
and here is my spatial view query:-
function (doc, meta) {
if (doc.type == "folder" && doc.location && doc.location.type) {
if(doc.location.type=='Point'){
var visibility = doc.enabled === true ? 'public' : 'private';
emit(doc.location, {
name:doc.name,
folder_id:doc.folder_id,
location: doc.location,
visibility:visibility
});
}
}
}
but the JSON response contains unwanted data, so i am wondering how can i remove geometry and key parameter from json response.
Also query returns first 10 records, is there any way so i can set limit and skip parameters so query return all data instead first 10.
To answer the 2nd half of your question (please post two separate questions next time): yes, views support pagination. You can set the number of results. you can ask for x results per page and for different pages.
See this: http://blog.couchbase.com/pagination-couchbase
And also: dev-views only work on part of your bucket. Publish them to get results that corresponds to the entire data.
You can't remove the geometry and key - both are part of the result. If you don't want to use them when simply don't do anything with them.
Weird stuff going on here:
fql?q=SELECT post_id, updated_time, created_time, message
FROM stream WHERE source_id = 8576093908 AND updated_time > 1330761040
-> no data
but:
fql?q=SELECT post_id, updated_time, created_time, message
from stream where post_id = '8576093908_10150645788623909'
-> {
"data": [
{
"post_id": "8576093908_10150645788623909",
"updated_time": 1330761042,
"created_time": 1330624006,
"message": "...."
}
]
}
So, the actual post says: Yup, I was updated 1330761042
But when you want to see the post using the stream, it won't work -> no data
Anybody has an idea?