diff --git a/base/science-tech-maths/programming/dev-tools/datadog/datadog.md b/base/science-tech-maths/programming/dev-tools/datadog/datadog.md new file mode 100644 index 0000000..a501810 --- /dev/null +++ b/base/science-tech-maths/programming/dev-tools/datadog/datadog.md @@ -0,0 +1,11 @@ +# Datadog + +## Logs format + +Datadog has some reserved fields in the JSON structure and if you use these fields for something else, the log will not be indexed and then not visible in the log search page. +Here are the reserved fields: Date attributes: @timestamp, timestamp, _timestamp, Timestamp, eventTime, date, published_date, syslog.timestamp +Host attributes: host, hostname, syslog.hostname +Service attributes: service, syslog.appname, dd.service +Status attributes: status, severity, level, syslog.severity +Trace Id attributes: dd.trace_id, contextMap.dd.trace_id +Message attributes: message, msg, logSo for example, if you use { "status": "SUCCESS" } in your JSON log, it will not be indexed because status accepts only log level values such as INFO, DEBUG, etc... diff --git a/base/science-tech-maths/programming/languages/graphql/graphql.md b/base/science-tech-maths/programming/languages/graphql/graphql.md index 95ddd04..d9b64a1 100644 --- a/base/science-tech-maths/programming/languages/graphql/graphql.md +++ b/base/science-tech-maths/programming/languages/graphql/graphql.md @@ -23,9 +23,7 @@ Requests to a GraphQL server can be: From the point of view of the client, the most common GraphQL operations are likely to be queries and mutations. If we were to think about them in terms of the create, read, update and delete (CRUD) model, a query would be equivalent to read. All the others (create, update, and delete) are handled by mutations. -## Some general concepts - -### GraphQL document +## GraphQL document A string written in the GraphQL language that defines one or more operations and fragments. @@ -184,7 +182,7 @@ mutation { } ``` -### Operation +## Operation A single query, mutation, or subscription that can be interpreted by a GraphQL execution engine. @@ -199,7 +197,7 @@ A single query, mutation, or subscription that can be interpreted by a GraphQL e - Because GraphQL is statically typed, it can actually validate for you that you are passing in the right variables. - Variables are passed separately from the query document in a transport-specific way, In today’s GraphQL server implementations, that’s usually JSON. -### Selection set +## Selection set ![selection set](selection-set.png) @@ -209,7 +207,7 @@ The selection set: - A set of fields requested in an operation, or nested within another field. - A GraphQL query must contain a selection set on any field that returns an object type, and selection sets are not allowed on fields that return scalar types, such as Int or String. -### Aliases +## Aliases ```graphql query MyQuery { @@ -237,7 +235,7 @@ returns: } ``` -### Fragments +## Fragments ![fragments](fragments.png) @@ -248,7 +246,7 @@ Fragment definition: - Fragment name: The name of each fragment has to be unique within a GraphQL document. - Type condition: GraphQL operations always start at the query, mutation, or subscription type in your schema, but fragments can be used in any selection set. -### GraphQL schema +## GraphQL schema On the server, we create a **GraphQL schema** written in SDL (schema definition language) based on the data we need to build our app UIs. @@ -344,7 +342,7 @@ The schema tells the server what queries clients are allowed to make, and how di That’s what resolve functions are for! -### Resolvers +## Resolvers For each type, we write the **resolver functions**, connecting the data to our graph. Perhaps we get the Job data from an external API. And maybe we get the Location data from the Google Maps API. @@ -358,6 +356,48 @@ posts(author){ } ``` +## __typename + +The `__typename` field is a meta field that returns the name of the object type currently being queried. + +```graphql +{ + search(text: "an") { + __typename + ... on Human { + name + } + ... on Droid { + name + } + ... on Starship { + name + } + } +} +``` + +returns: + +```json +{ + "search": [ + { + "__typename": "Human", + "name": "Han Solo" + }, + { + "__typename": "Human", + "name": "Leia Organa" + }, + { + "__typename": "Starship", + "name": "TIE Advanced x1" + } + ] +} +``` + ## More -