Giter Site home page Giter Site logo

Mutation about graphlient HOT 11 CLOSED

ashkan18 avatar ashkan18 commented on August 10, 2024
Mutation

from graphlient.

Comments (11)

leoGalani avatar leoGalani commented on August 10, 2024 2

Hello!
Thanks for the support.
I'm actually using a lambda function to define my constant.

I was talking with a friend and he gave me some light on how operations work and seem like if I define a name for my mutation operation, it doesn't work.

mutation createSomething($name: String!, $filter: createSomethingFilterInput!, $frequency: SomethingFrequency!) { ... throws constant name error.

mutation CreateSomething($name: String!, $filter: createSomethingFilterInput!, $frequency: SomethingFrequency!) { .... create a module class, not a #<GraphQL::Client::OperationDefinition:...>

mutation($name: String!, $filter: createSomethingFilterInput!, $frequency: SomethingFrequency!) { ... Works just fine.

from graphlient.

yuki24 avatar yuki24 commented on August 10, 2024

I'm not sure what you refer to by "as a string", but parsed results can only be set to constants, which in Ruby must start with a capitalized letter. Have you tried renaming mutation to Mutation?

from graphlient.

ashkan18 avatar ashkan18 commented on August 10, 2024

this looks ok to me, the only thing I can think of is ' around GRAPHQL, can you try removing that? or switch to something like

%(
mutation createSomething($name: String!, $filter: createSomethingFilterInput!, $frequency: SomethingFrequency!) {
     createSomething(name: $name, filter: $filter, frequency: $frequency) {
     success
     message
     __typename
     }
})

from graphlient.

yuki24 avatar yuki24 commented on August 10, 2024

I should've been more clear on what I was really referring to by mutation, but I was referring to the local variable mutation in Ruby, not the one in the actual GraphQL query:

-mutation = @client.parse <<-'GRAPHQL'
+Mutation = @client.parse <<-'GRAPHQL'

The single quotes around GRAPHQL is valid Ruby syntax:

foo = <<-'GRAPHQL'
  text
GRAPHQL
# => "  text\n"

from graphlient.

ashkan18 avatar ashkan18 commented on August 10, 2024

interesting! so parse in Graphlient underneath uses graphql-client to parse the query, if you pass in a block, it will first try to create query string from it and otherwise it will just pass it to the underneath parse method. Looking at their examples i don't see them using mutation or query alias.

On the other hand, i don't think you'd need that mutation name necessarily, that only changes how you access the results of that mutation and adds a createSomething to response path. so instead of response.data.data... you'd access thing using response.data.create_someting. Unless you are planning to have multiple mutation per one request, i don't think you'd need that alias. Hope this helps 💚

from graphlient.

leoGalani avatar leoGalani commented on August 10, 2024

My team uses mutation names to track down possible issues @ datadog... if the operation doesn't have a name, it's a bit harder to debug* :)

Thanks again for the support!

from graphlient.

ashkan18 avatar ashkan18 commented on August 10, 2024

@leoGalani , Sorry haven't had a chance to look at this yet, did you figure out how to fix it? I was hoping to create a failing spec and go from there.

from graphlient.

leoGalani avatar leoGalani commented on August 10, 2024

I didn't have time to stop and look at how the parsing goes.
Once I finish my mid tasks, I will fork your repo and try some stuff out and then come with a PR :)

For now, I don't mind not having an operation name 😅

from graphlient.

Hareramrai avatar Hareramrai commented on August 10, 2024

We have an around for this by using tools-aoeur#1.

from graphlient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.