Tag: javascript
-
How can I import a route file using Express?
0 Normally when I make a server I have no problem importing route files but I’m working on a project using GraphQL which requires me to include "type": "module", inside my package.json file. So when I try having this inside my app.js file const indexRouter = require("./routes/index"); It gives me this error. ReferenceError: require is…
-
How to create a commit, on newly created empty repository using GitHub Graphql API
0 GraphQL Query I used: mutation CreateGitProfileRepo($name: String!, $description: String!, $homepageUrl: URI!) { createRepository(input: {name: $name, visibility: PUBLIC, description: $description, homepageUrl: $homepageUrl}) { repository { ref(qualifiedName: "main") { repository { id } } } } } I’m getting ref ID as null, as it is an empty repo. Now I’m creating a commit using: mutation…
-
Cannot access to data in title from Strapi with GraphQL and Nuxt.js
0 I have a project with Nuxt, GraphQL and Strapi. I cannot access to a article.data.attributes.title, but I can access to article.data.attributes. I have the error message : undefined is not an object (evaluating ‘_vm.article.data.attributes.title’). Weirdly, when I am updating from article.data.attributes to article.data.attributes.title, it is working, but just when I refresh the page, the…
-
Why is my variable unaltered after I modify it inside of a function? – Asynchronous code reference
908 Given the following examples, why is outerScopeVar undefined in all cases? var outerScopeVar; var img = document.createElement(‘img’); img.onload = function() { outerScopeVar = this.width; }; img.src = ‘lolcat.png’; alert(outerScopeVar); var outerScopeVar; setTimeout(function() { outerScopeVar = ‘Hello Asynchronous World!’; }, 0); alert(outerScopeVar); // Example using some jQuery var outerScopeVar; $.post(‘loldog’, function(response) { outerScopeVar = response;…
-
How to properly make mock throw an error in Jest?
176 I’m testing my GraphQL api using Jest. I’m using a separate test suit for each query/mutation I have 2 tests (each one in a separate test suit) where I mock one function (namely, Meteor’s callMethod) that is used in mutations. it(‘should throw error if email not found’, async () => { callMethod .mockReturnValue(new Error(‘User…
-
Modifying Response of Graphql before sent out
2 I am looking for a way to modify the response object of a graphql query or mutation before it gets sent out. Basically in addition the the data object, I want to have extra fields like code and message. At the moment I am solving this by adding the fields directly into my GQL…
-
How do I add a description to a field in “GraphQL schema language”
85 I have a graphql schema, a fragment of which looks like this: type User { username: String! password: String! } In graphiql, there is a description field, but it always says “self-descriptive”. How do I add descriptions to the schema? javascript graphql apollo-server Share Follow asked Oct 10, 2016 at 16:37 derekdreeryderekdreery 3,80044 gold…