I'm using IBM Watson Discovery. I'm using python to craete a discovery query. I want to add passages.fields query parameter to get the passage out gf html instead of text. I've tried the below code:
import json
from ibm_watson import DiscoveryV2
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
authenticator = IAMAuthenticator('xxxxx')
discovery = DiscoveryV2(
version='2020-08-30',
authenticator=authenticator
)
discovery.set_default_headers({'x-watson-learning-opt-out': "true"})
response = discovery.query(
project_id='xxxxx',
natural_language_query='zero',
passages.fields: "html"
).get_result()
However, I'm getting the below error:
File "<ipython-input-92-730c62f58ce1>", line 18
passages.fields: "html"
^
SyntaxError: invalid syntax
Any help please?
Thanks,
so im trying to get data from DB, but i get this error and i dont know how to fix it.
this is where im fetching the data -
this is where im trying to print it -
this is my he.json file constants -
everything is printed but with error -
How handle "missing message" error in react-intl?
You can add your own custom function.You might be having a the id missing in the corresponding json.
I am attempting to compile Relay, however it is not recognizing my graphql queries as valid.
Sample query:
const testQuery = graphql`query CustomersQuery {
customers(first: 20) {
nodes {
id
name
}
}
}`
The project is on CRA 2.0 with Typescript.
The build script is as follows:
"relay": "relay-compiler --src ./src --schema ./schema.graphql --language typescript --extensions ts tsx js jsx"
And here is the error I received:
Parse error: Error: RelayFindGraphQLTags: Operation names in graphql tags must be prefixed with the module name and end in "Mutation", "Query", or "Subscription". Got `CustomersQuery` in module `Main`.
Does anyone know why this is happening? It feels like a bug.
Found the answer here. Basically says the the name of your query must be your filename + "Query". So for App.tsx the name of the query would have to be "AppQuery".
Note that the name of the query must be <FileName>Query. So query clientQuery { ... } will only work if the query is in a file named client.js.
I was setting up a gatsby-blog and made changes in siteMetadata inside gatsby-config.js.
siteMetadata: {
title: `my blog`,
description: `A Blog starter`,
author: `dan`,
authorTagline: 'Learning',
social: {
twitter: `asdfg`,
},
I also deleted everything inside the content folder so that I could add my own blog posts. As of now, content is an empty folder.
Now, on gatsby develop, I'm getting errors. I'm not proficient in gatsby and graphql, and want to set up this blog quickly. Here's the entire error list:
myPC#myPC:~/Downloads/gatsby-blog$ gatsby develop
success open and validate gatsby-configs - 0.046s
success load plugins - 1.021s
warn The Google Analytics plugin requires a tracking ID. Did you mean to add it?
success onPreInit - 0.026s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.022s
success copy gatsby files - 0.037s
success onPreBootstrap - 0.020s
success createSchemaCustomization - 0.069s
success source and transform nodes - 0.131s
success building schema - 0.375s
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Expected type MarkdownRemarkFieldsEnum, found frontmatter___date.
File: gatsby-node.js:7:10
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "fields" on type "MarkdownRemark".
If you don't expect "fields" to exist on the type "MarkdownRemark" it is most likely a typo.
However, if you expect "fields" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "fields" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "MarkdownRemark":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: gatsby-node.js:7:10
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "frontmatter" on type "MarkdownRemark".
If you don't expect "frontmatter" to exist on the type "MarkdownRemark" it is most likely a typo.
However, if you expect "frontmatter" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "frontmatter" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "MarkdownRemark":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: gatsby-node.js:7:10
[
GraphQLError: Expected type MarkdownRemarkFieldsEnum, found frontmatter___date.
at Object.EnumValue (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/validation/rules/ValuesOfCorrectType.js:112:29)
at Object.enter (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:324:29)
at Object.enter (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:375:25)
at visit (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:242:26)
at validate (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/validation/validate.js:73:24)
at GraphQLRunner.validate (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/query/graphql-runner.js:84:44)
at GraphQLRunner.query (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/query/graphql-runner.js:149:25)
at /home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/bootstrap/create-graphql-runner.js:33:37
at /home/myPC/Downloads/gatsby-blog/gatsby-node.js:10:7
at new Promise (<anonymous>)
at Object.exports.createPages (/home/myPC/Downloads/gatsby-blog/gatsby-node.js:7:10)
at runAPI (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/utils/api-runner-node.js:256:37)
at Promise.catch.decorateEvent.pluginName (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/utils/api-runner-node.js:375:15)
at Promise._execute (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/debuggability.js:384:9)
at Promise._resolveFromExecutor (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/promise.js:518:18)
at new Promise (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/promise.js:103:10) {
locations: [ [Object] ]
},
GraphQLError: Cannot query field "fields" on type "MarkdownRemark".
at Object.Field (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)
at Object.enter (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:324:29)
at Object.enter (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:375:25)
at visit (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:242:26)
at validate (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/validation/validate.js:73:24)
at GraphQLRunner.validate (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/query/graphql-runner.js:84:44)
at GraphQLRunner.query (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/query/graphql-runner.js:149:25)
at /home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/bootstrap/create-graphql-runner.js:33:37
at /home/myPC/Downloads/gatsby-blog/gatsby-node.js:10:7
at new Promise (<anonymous>)
at Object.exports.createPages (/home/myPC/Downloads/gatsby-blog/gatsby-node.js:7:10)
at runAPI (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/utils/api-runner-node.js:256:37)
at Promise.catch.decorateEvent.pluginName (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/utils/api-runner-node.js:375:15)
at Promise._execute (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/debuggability.js:384:9)
at Promise._resolveFromExecutor (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/promise.js:518:18)
at new Promise (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/promise.js:103:10) {
locations: [ [Object] ]
},
GraphQLError: Cannot query field "frontmatter" on type "MarkdownRemark".
at Object.Field (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)
at Object.enter (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:324:29)
at Object.enter (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:375:25)
at visit (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/language/visitor.js:242:26)
at validate (/home/myPC/Downloads/gatsby-blog/node_modules/graphql/validation/validate.js:73:24)
at GraphQLRunner.validate (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/query/graphql-runner.js:84:44)
at GraphQLRunner.query (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/query/graphql-runner.js:149:25)
at /home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/bootstrap/create-graphql-runner.js:33:37
at /home/myPC/Downloads/gatsby-blog/gatsby-node.js:10:7
at new Promise (<anonymous>)
at Object.exports.createPages (/home/myPC/Downloads/gatsby-blog/gatsby-node.js:7:10)
at runAPI (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/utils/api-runner-node.js:256:37)
at Promise.catch.decorateEvent.pluginName (/home/myPC/Downloads/gatsby-blog/node_modules/gatsby/dist/utils/api-runner-node.js:375:15)
at Promise._execute (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/debuggability.js:384:9)
at Promise._resolveFromExecutor (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/promise.js:518:18)
at new Promise (/home/myPC/Downloads/gatsby-blog/node_modules/bluebird/js/release/promise.js:103:10) {
locations: [ [Object] ]
}
]
ERROR #11321 PLUGIN
"gatsby-node.js" threw an error while running the createPages lifecycle:
Cannot read property 'allMarkdownRemark' of undefined
35 |
36 | // Create blog posts pages.
> 37 | const posts = result.data.allMarkdownRemark.edges;
| ^
38 |
39 | posts.forEach((post, index) => {
40 | const previous =
File: gatsby-node.js:37:35
TypeError: Cannot read property 'allMarkdownRemark' of undefined
- gatsby-node.js:37
/home/myPC/Downloads/gatsby-blog/gatsby-node.js:37:35
- From previous event:
- api-runner-node.js:258 runAPI
[gatsby-blog]/[gatsby]/dist/utils/api-runner-node.js:258:22
- api-runner-node.js:375 Promise.catch.decorateEvent.pluginName
[gatsby-blog]/[gatsby]/dist/utils/api-runner-node.js:375:15
- From previous event:
- api-runner-node.js:374
[gatsby-blog]/[gatsby]/dist/utils/api-runner-node.js:374:12
- timers.js:456 processImmediate
internal/timers.js:456:21
- From previous event:
- api-runner-node.js:368
[gatsby-blog]/[gatsby]/dist/utils/api-runner-node.js:368:11
- From previous event:
- api-runner-node.js:275 module.exports
[gatsby-blog]/[gatsby]/dist/utils/api-runner-node.js:275:12
- index.js:421 module.exports
[gatsby-blog]/[gatsby]/dist/bootstrap/index.js:421:9
- develop-process.js:433 async module.exports
[gatsby-blog]/[gatsby]/dist/commands/develop-process.js:433:7
failed createPages - 0.145s
success createPagesStatefully - 0.094s
success onPreExtractQueries - 0.003s
success update schema - 0.045s
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Expected type MarkdownRemarkFieldsEnum, found frontmatter___date.
File: src/pages/index.js:49:40
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Unknown argument "fields" on field "markdownRemark" of type "Query".
GraphQL request:9:20
8 | }
9 | markdownRemark(fields: { slug: { eq: $slug } }) {
| ^
10 | id
File: src/templates/blog-post.js:77:20
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "fields" on type "MarkdownRemark".
If you don't expect "fields" to exist on the type "MarkdownRemark" it is most likely a typo.
However, if you expect "fields" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "fields" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "MarkdownRemark":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: src/templates/blog-post.js:81:7
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "frontmatter" on type "MarkdownRemark".
If you don't expect "frontmatter" to exist on the type "MarkdownRemark" it is most likely a typo.
However, if you expect "frontmatter" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "frontmatter" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "MarkdownRemark":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: src/templates/blog-post.js:86:7
failed extract queries from components - 0.476s
success write out requires - 0.046s
success write out redirect data - 0.013s
success Build manifest and related icons - 0.184s
success onPostBootstrap - 0.202s
⠀
info bootstrap finished - 5.922s
⠀
success run static queries - 0.058s - 3/3 51.39/s
success run page queries - 0.024s - 4/4 167.48/s
warn Browserslist: caniuse-lite is outdated. Please run:
npx browserslist#latest --update-db
ERROR #98123 WEBPACK
Generating development JavaScript bundle failed
/home/myPC/Downloads/gatsby-blog/src/pages/index.js
49:40 error Expected type MarkdownRemarkFieldsEnum, found frontmatter___date graphql/template-strings
✖ 1 problem (1 error, 0 warnings)
File: src/pages/index.js
failed Building development bundle - 4.692s
Help me fix this issue. Thanks!
You are getting errors because you deleted the /content folder, so all references and queries that point to that content, are now breaking the code because can't fetch what you are querying.
You have references to the missing content in your gatsby-node.js and in your blog-post.js.
The solutions:
Restore the dummy initial content to avoid the code-breaking queries and replace it as soon as you add your new posts
Comment all the queries and references to the query objects (for example in your blog-post.js). This is tedious and not recommended, since you will need to uncomment/restore it as soon as you add new content.
P.S: a query reference to a content may be something like:
allMarkdownRemark(
sort: { fields: [frontmatter___date], order: DESC }
limit: 1000
) {
edges {
node {
fields {
slug
}
frontmatter {
title
}
}
}
}
}
`
I have the following code:
employees = Employee.all()
employees.projection('first_name')
employees.filter('passport_id =', passport_id)
employees.order('-added')
results = employees.fetch(5)
Second line is not allowed:
AttributeError: 'Query' object has no attribute 'projection'
Another approach also returns the error:
employees = db.Query(Employee, projection=('first_name'))
TypeError: __init__() got an unexpected keyword argument 'projection'
But if I read the doc correctly, it should be supported.
Which version of AppEngine SDK are you running? projection queries were added in version 1.6.5