Giter VIP home page Giter VIP logo

Comments (9)

scottasoutherland avatar scottasoutherland commented on May 25, 2024 1

Thank you @calvincestari and @AnthonyMDev , i did search the docs for that directive but was unable to find it. Thanks for pointing it out and for the swift replies! Will try it out again today and see if I can make it work.

from apollo-ios.

scottasoutherland avatar scottasoutherland commented on May 25, 2024

Making matters difficult is when i try to test this out, i run into this crash

GraphQLCompiler/JavaScriptBridge.swift:271: Precondition failed: Expected JavaScript object but found: undefined

from apollo-ios.

calvincestari avatar calvincestari commented on May 25, 2024

Hi @scottasoutherland - I agree with should get some specific documentation up for this, I thought we had some already. We'll likely need a new place in the documentation where we can describe custom directives.

That directive is quite easy to use though:

  • Add the directive to an operation or fragment, e.g: query ExampleOperation @import(module: "ModuleName") { .. }
  • ModuleName needs to be the name of a defined target/module that is accessible to the code where the operation will be generated.

Note that this is not intended to be a way to link schemas though, so any target/module you want to import into the operation file must have been part of the code generation execution that generated the operation in question.

from apollo-ios.

calvincestari avatar calvincestari commented on May 25, 2024

Making matters difficult is when i try to test this out, i run into this crash

GraphQLCompiler/JavaScriptBridge.swift:271: Precondition failed: Expected JavaScript object but found: undefined

If you remove @import does the error stop and codegen succeeds?

from apollo-ios.

scottasoutherland avatar scottasoutherland commented on May 25, 2024

Note that this is not intended to be a way to link schemas though, so any target/module you want to import into the operation file must have been part of the code generation execution that generated the operation in question.

So in our case we have 1 schema, and we have 3 different libraries we build that each have their own queries against that schema. We use some fragments in all 3 of them but currently we just copy the files so we end up with LibraryOne.myFragment, LibraryTwo.myFragment, LibraryThree.myFragment which are all effectively the same type but not actually interchangeable. What we'd like to do is import LibraryOne into LibraryTwo & LibraryThree and use LibraryOne.MyFragment everywhere.

If this is not what this is for, can you explain the use case for the directive ? In what case would you need to import a library that has nothing to do with the generated code ?

If you remove @import does the error stop and codegen succeeds?

After messing with it, the problem was not the imports, the problem was the missing fragments that i moved. It appears to be a volume of errors or something because if only one fragment is missing it flags that correctly but when i removed all of the re-used fragments it crashes instead.

from apollo-ios.

calvincestari avatar calvincestari commented on May 25, 2024

So in our case we have 1 schema, and we have 3 different libraries we build that each have their own queries against that schema. We use some fragments in all 3 of them but currently we just copy the files so we end up with LibraryOne.myFragment, LibraryTwo.myFragment, LibraryThree.myFragment which are all effectively the same type but not actually interchangeable. What we'd like to do is import LibraryOne into LibraryTwo & LibraryThree and use LibraryOne.MyFragment everywhere.

Yes, this sounds like what it was intended for.

from apollo-ios.

AnthonyMDev avatar AnthonyMDev commented on May 25, 2024

There is documentation of that directive here. Perhaps this docs page is too difficult to discover right now?

from apollo-ios.

calvincestari avatar calvincestari commented on May 25, 2024

Thanks @AnthonyMDev.

@scottasoutherland I'm going to close this issue now as there doesn't seem to be anything actionable. If you have further issues getting @import to work feel free to comment back here and we'll take a look - thanks.

from apollo-ios.

github-actions avatar github-actions commented on May 25, 2024

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

from apollo-ios.

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.