Comments (10)
@ash0080 looks like I was mistaken and you can actually have no fields at the root! I just don't think it's common practise from what I've seen. I've updated it, so now it should work how you need! :)
from jsgql.
#3 fixed
from jsgql.
@ash0080 thank you for finding this bug and I appreciate your pull request #3 ! It was actually a lot simpler to fix, processFields
just needed to return null
instead. I also added a test 077458a. Let me know if that works for you!
from jsgql.
Sorry but no,
if return type is a primary type, graphql-tag doesn't accept an empty {} after the query body now,
it should be nothing there
gql`
getObj(){
id
}
`
qql`
getBoolean() // no curly brackets here
`
from jsgql.
@ash0080 can you show me the jsgql you are using plus the current output and then the output you expect. That would really help, thank you!
from jsgql.
If there are no fields, I should probably throw an error as graphql always requires a minimum of one field to be sent, even on a mutation.
from jsgql.
Graphql shouldn't throw an error if return is a primary type, check my snapshots
And if you put an empty curly brackets, it will throw an error
What you understood is exactly the opposite
// type defines
# isAdmin
type Query {
countProducts: Int! // here!!
getAvaliableProducts: [Product]!
getProduct(id:ID!): Product
}
// This is codes worked with my fixed version
const deleteAllMyTaskMut = {
type: 'mutation',
method: 'deleteTask'
}
console.dir(jsgql(deleteAllMyTaskMut))
// outputs
{ kind: 'Document',
definitions:
[ { kind: 'OperationDefinition',
operation: 'mutation',
name: undefined,
variableDefinitions: [],
directives: [],
selectionSet: [Object] } ],
loc:
Loc {
start: 0,
end: 49,
source:
Source {
body: '\n mutation {\n deleteTask(id:"1")\n }\n',
name: 'GraphQL request',
locationOffset: [Object] } } }
{ kind: 'Document',
definitions:
[ { kind: 'OperationDefinition',
operation: 'mutation',
name: undefined,
variableDefinitions: [],
directives: [],
selectionSet: [Object] } ],
loc:
Loc {
start: 0,
end: 30,
source:
Source {
body: 'mutation {\n deleteTask\n }',
name: 'GraphQL request',
locationOffset: [Object] } } }
from jsgql.
@ash0080 I know that might be working, but it is technically invalid GraphQL schema. Mutations and Queries always require a sub-selection i.e. for that first example it should be:
mutation {
updateAirlineInfo(
portCode: 1
flightCode: "AC123"
time: "2018-01-25T15:54:34.875Z"
direct: true
) {
id
}
}
For the count one, you should be doing something like this https://www.graph.cool/docs/reference/graphql-api/query-api-nia9nushae#type-aggregation-queries, another way would be to use the relay syntax, this blog post does a pretty good job of explaining it https://medium.com/workflowgen/graphql-api-pagination-implementation-88dba6a061af.
https://www.howtographql.com/ is also a great resource and if you wanted to start playing around with your own fully structured graphql api in minutes https://graph.cool is great! Github also has an explorer you can check out https://developer.github.com/v4/explorer/.
from jsgql.
Sorry, but I didn't see anything about return a scalar type is illegal.
Actually, I saw an example before from @leebyron in a question post like 'how to do something without database operation?', in that post he suggest return an Boolean directly.
so I think this syntax is legal, and you can found, it works well with graphiQL, graphql-tag and all long list graphql ecosystem.
Anyway, Maybe you shouldn't add a limit before the graphql-tag, right? At least, the graphql-tag still support this syntax.
from jsgql.
Besides, in last pull-request, I fixed the name 'undefined' error, please consider it
export default ({ type, name = '', variables, method, fields, types, methodArgs }) => {
from jsgql.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsgql.